oshirowanen
oshirowanen

Reputation: 15925

Center div in IE5.x?

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?

Upvotes: 1

Views: 1287

Answers (2)

MrJoshFisher
MrJoshFisher

Reputation: 1123

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

Upvotes: 0

Quentin
Quentin

Reputation: 944054

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

Upvotes: 7

Related Questions