Reputation: 21848
Is there a non-javascript way to center the very first container div of a page which would work with IE, FF as well as chrome?
margin:0 auto;
does not work in IE8 :(
Upvotes: 1
Views: 111
Reputation: 11205
margin: 0 auto;
works in all browsers (even as far as IE6).
You are either
width
property so your container is actually centered it's just covering 100% of the width, orcolor
or debug with firebugUpvotes: 1
Reputation: 122
It works in IE8 but you have to notice IE8 that its a good idea to visualize your webpage with the IE8 standard mode... :S by this tag in the header:
<meta http-equiv="x-ua-compatible" content="IE=8"/>
Upvotes: 0
Reputation: 26922
That should most certainly work in IE8, the reason why it doesn't work for you could be that your IE is in quirks mode, possibly due to a missing DocType. Try this:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="width:50%;margin:auto;border:1px solid black;">TEST</div>
</body>
</html>
Upvotes: 3
Reputation: 944069
margin:0 auto;
works in IE8 if you have a Doctype that triggers standards mode.
If you don't have one, you should. If you really don't want one then you can hack around it.
Upvotes: 1
Reputation: 21848
I found a not-so-good workaround for this
http://www.bluerobot.com/web/css/center1.html
If someone knows a better solution, please mention it here.
Upvotes: 0