I am sort of new to using CSS and HTML and I am having trouble with the IE/Firefox browser conflict. I am trying to center my site (which isnt finished) but IE is not centering it like it does in Firefox. Here is the webpage www.breakpointdesigns.com/nathan (Im not involved in the main site yet) He is the code <html> <head> <style type="text/css"> #center { width:671px; margin:0px auto; text-align:left; } #width { width:671px; } #header { width:671px; height:96px; } #top_gradient { width:611px; float:left; height:18px; background-image:url("images/top-gradient.gif"); background-repeat:repeat-x; } </style> </head> <body> <div id="center"> <div id="width"> <div id="header"> <div id="top_gradient"> </div> </div> </div> </div> </body> </html> Code (markup): Could you please tell me how I can center the page in both IE and Firefox?
ie will use text-align to center so try putting in body {text-align: center;} into your css. that should fix it up/
thank you, it worked here is my new code for anyone who is curious <html> <head> <style type="text/css"> body { text-align: center; } #center { width:671px; margin:0px auto; text-align:left; } #width { width:671px; } #header { width:671px; height:96px; } #top_gradient { width:611px; float:left; height:18px; background-image:url("images/top-gradient.gif"); background-repeat:repeat-x; } </style> </head> <body> <div id="center"> <div id="width"> <div id="header"> <div id="top_gradient"> </div> </div> </div> </div> </body> </html> Code (markup):
wow - kewl. I always did a center div then a left div which allways worked but this does the same thing - thanks man!
If you use a complete and proper DTD as the first line of your document, IE will render in standards mode. Else, it is in quirks mode, where it does not support margin-left | right: auto; In standards mode, IE has pretty good support for css1. cheers, gary
I was just about to suggest the same thing, Gary. Use a proper DOCTYPE. I prefer XHTML Strict, but others get along just fine with HTML 4.01 Strict, or even a Transitional flavor of either HTML or XHTML. Just pick something that works for you and go with it until you feel more comfortable using something else. Good luck and happy coding!
Like others have said, use a doctype. Also, you don't need margin:0px auto It's better not to specify a type of measurement when your value is 0. Instead use, margin: 0 auto;