Center Div in HTML
Problem: We need to align our fixed width div container in the center of the browser. IE does not render this the same
as Firefox.
In Firefox, all we need is:
margin: 0 auto
Internet Explorer is a bit trickier. Try:
body {
text-align: center;
}
#container {
text-align: left;
}
This will align the container to the center with the text within the div back left justified.text-align: center;
}
#container {
text-align: left;
}
<body>
<div id="container" >
Hello World
</div>
</body>
<div id="container" >
Hello World
</div>
</body>
This CSS code should work with IE and Firefox:
body {
text-align: center
}
#container {
width: 960px;
margin: 0 auto;
text-align: left
}
text-align: center
}
#container {
width: 960px;
margin: 0 auto;
text-align: left
}
