I’m trying to align a div horizontally, but for some reason it’s not working in IE… What am I doing wrong?
HTML
<body>
<div id="container">
<div id="header">
<img src="logo.png">
</div>
<div id="top-nav">
<ul class="menu">
<li class="first leaf menu-mlid-471"><a href="">Home</a></li>
</ul>
</div>
</div>
</body>
CSS
body{
background-color: #fff;
margin: 0;
padding: 0;
}
ul.menu{
width: 500px;
margin: auto;
}
#header{
height: 150px;
}
For Firefox, Chrome, Safari,… no problem. It all comes exactly in the middle. But IE refuses to align it properly…
Do you have a doctype? Without it, IE reverts to Quirks Mode, which does not support
margin: auto;centering.Also, IE < 6 does not support
margin: auto;centering at all (in case ancient IE browser compliance is particularly important you).