I am working on a new design and It is not centering in IE . It centers fine in Firefox, Safari, and Opera but not IE . Got any ideas of what the problem is.
Use a strict doctype - a transitional doctype forces IE6 into quirks mode and the margin:0 auto; is unrecognised. In strict (standards mode) your site should centre without problems.
Use a strict doctype - a transitional doctype forces IE6 into quirks mode and the margin:0 auto; is unrecognised. In strict (standards mode) your site should centre without problems.
You were write . I changed the doctype and my problem is now fixed. Thanks.
You could also add text-align:center; to the body and then set the text-align back to left in your page-wrap. I think that's maybe a better way to do it.
Why? It isn't necessary. All you end up doing is adding unnecessary extra CSS and in some cases having to add an extra div to your HTML as a page wrap. Not all layouts require a separate wrapper div in addition to the body element.
Using text-align:center; to force a web page to centre is a hack in my view and certainly not necessary for IE6 or later. For eariler IE's (for anyone suicidal enough to still build for them) then indeed you'll use the text-align:center; hack to centre your site via a conditional stylesheet. But really, anyone still using IE5.5 or earlier to browse the web will be well used to broken web sites ;) and the worst that would happen in those very old browsers is that the site will be left aligned, so still otherwise fully functional.
I have everything within a page wrap.
The HTML:
<div id="page-wrap"> </div>
The CSS :
#page-wrap{
width: 950px;
margin:0 auto;
}
How's that.
You were write . I changed the doctype and my problem is now fixed. Thanks.
Why? It isn't necessary. All you end up doing is adding unnecessary extra CSS and in some cases having to add an extra div to your HTML as a page wrap. Not all layouts require a separate wrapper div in addition to the body element.
that being said who still codes for IE4 & IE5