Question

I have the following HTML:

<div id="container">
    <div id="header"><h1>Sed sollicitudin dignissim justo, sed.</h1></div>
</div>

and the following CSS:

div#container
{
    text-align:left;
    width:500px;
    margin:0 auto;
}

This creates a div container which spans across the whole screen, and another div header within the first div container, where the second div has a fixed width and is centered in the first div.

This works fine in IE6 but in IE5.x, it doesn't seem to center, it is aligned to the left of the screen.

How do I center this in IE5.x?

Was it helpful?

Solution

IE 5.x centres blocks as if there were inline elements.

#containers_parent { text-align: center; }
#container { text-align: left; } /* To reset the alignment for the text inside */

OTHER TIPS

if the only thing you have on the page is #container just add <center> at the top

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top