سؤال

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?

هل كانت مفيدة؟

المحلول

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 */

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top