|
How to center your outter div tag in IE |
|
Sunday, 10 February 2008 |
It's possible to center your outter div tag in IE without regressing to table tags. Many hacks offered in forum posts returned by Google searches don't work. Developers offer these recommendations confidently, and then you try it, and nothing. How do these posts have such high Google rankings I wonder. This solution worked for me, finally.
Say your main div tag looks like this:
<div id="main">
<div id="header"></div>
</div>
And you want the div "main" to be say, 900px, and centered in the middle of any browser (yes, including IE). These are the styles that you need. Add the attributes to these existing styles
body {
text-align: center;
}
and
#main {
width:900px;
margin: 0 auto 0 auto;
text-align: left;
}
|