niche Posted December 3, 2009 Share Posted December 3, 2009 How do I center this form so it stays centered when I adjust the size of my browser window? <form> First name: <input type="text" name="firstname" /> <br /> Last name: <input type="text" name="lastname" /></form> Thank-you. Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 try<form style="margin: 0 auto">; Link to comment Share on other sites More sharing options...
niche Posted December 3, 2009 Author Share Posted December 3, 2009 Thanks, but it didn't work. Any other ideas other than align? Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 is the form in a div? What's its context? Link to comment Share on other sites More sharing options...
niche Posted December 3, 2009 Author Share Posted December 3, 2009 No it's not and there's no real context. I'm just trying to decide how to center this example I thought about using the align attribute in the div tag, but it's depreciated. How would you center this form? <form>First name:<input type="text" name="firstname" /><br />Last name:<input type="text" name="lastname" /></form> Thanks. Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 well, that's why I was asking if it is was in a div. I think centering something requires something relative to center it too. So, is it in a div? What is it in? Putting it in some sort of container and then applying those centering styles to it might work. Link to comment Share on other sites More sharing options...
niche Posted December 3, 2009 Author Share Posted December 3, 2009 Here's what I did and it works. I didn't think the CSS property, text-align, would work on a form in a div tag! Thanks for your help. <style type="text/css"> div {text-align:right}</style><div> <table cellpadding="5"> <form> First name: <input type="text" name="firstname" /> <br /> Last name: <input type="text" name="lastname" /> </form> </table></div> Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 I'm kind of surprised too. Link to comment Share on other sites More sharing options...
Ingolme Posted December 3, 2009 Share Posted December 3, 2009 The text-align property affects all the text that is within the element and its descendents.What is the table for? Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 yeah, but he had it justified right, and he wanted it centered. Plus he had that table in there. Link to comment Share on other sites More sharing options...
bladexhunt Posted December 16, 2009 Share Posted December 16, 2009 if you don't want to use the div align, try putting in a margin-left: auto, margin-right: auto, together they center the block level element. Link to comment Share on other sites More sharing options...
cofusion Posted December 16, 2009 Share Posted December 16, 2009 <center></center>that should work, if not try-<div align="center"></div>if not that try doing it from a style sheet. Link to comment Share on other sites More sharing options...
thescientist Posted December 17, 2009 Share Posted December 17, 2009 do not use <center> tags, instead use CSS for styling page elements. Link to comment Share on other sites More sharing options...
cofusion Posted December 17, 2009 Share Posted December 17, 2009 do not use <center> tags, instead use CSS for styling page elements.i said that as an option, but since it does not look like he is using a style sheet i named that last. Link to comment Share on other sites More sharing options...
roundcorners Posted December 17, 2009 Share Posted December 17, 2009 <center></center>that should work, if not try-<div align="center"></div>if not that try doing it from a style sheet.You really shouldn't be encouraging people to use deprecated elements and attributes Link to comment Share on other sites More sharing options...
cofusion Posted December 17, 2009 Share Posted December 17, 2009 You really shouldn't be encouraging people to use deprecated elements and attributesif your not using css it is fine to use. if he was using css i would have only said the css way. Link to comment Share on other sites More sharing options...
ShadowMage Posted December 17, 2009 Share Posted December 17, 2009 if your not using css it is fine to use. if he was using css i would have only said the css way.If you're using it on a home or office intranet and using browsers that support it, it's fine to use.The point roundcorners is trying to make is that it won't be standards compliant and therefore may not work on some users browsers. Link to comment Share on other sites More sharing options...
thescientist Posted December 18, 2009 Share Posted December 18, 2009 and since we're all here to learn and teach, why waste time with the wrong/non-standard/lazy way? Link to comment Share on other sites More sharing options...
cofusion Posted December 19, 2009 Share Posted December 19, 2009 and since we're all here to learn and teach, why waste time with the wrong/non-standard/lazy way?well i dont use that way, in my post i gave that way, the div way, and the css way. Link to comment Share on other sites More sharing options...
thescientist Posted December 19, 2009 Share Posted December 19, 2009 we are just merely suggesting that it is not helpful to promote the wrong way. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.