Reputation:
I have some centered content within a div. It shows up fine in Firefox/Chrome. In IE6 the content expands beyond the div to the entire browser window. Any idea what could be causing this?
Upvotes: 0
Views: 502
Reputation: 23311
The thing to do is to have text-align: center on a parent div e.g. body, so that your content div is centered in IE6.
Then use margin: auto on the content block to make sure the div is centered in better browsers.
body {
text-align: center;
}
#content {
width: 500px;
margin-left:auto;
margin-right:auto;
}
Upvotes: 1
Reputation: 7450
The <center> tag is deprecated. You should do something like this:
<div style="text-align:center; margin: 0 auto; width: 400px;">
</div>
That way you will have centered content.
Upvotes: 0
Reputation: 245459
Make sure you have the doctype definition at the top of your page. Otherwise, IE6 will open the page in quirks mode which can screw all kinds of stuff up...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Upvotes: 0