Click to See Complete Forum and Search --> : Centering content with IE


derekjackson
03-01-2006, 07:02 AM
Hi,
to centre my main site content, I've been using a style for the overall site DIV of:

margin-left: auto; margin-right: auto; margin-bottom: auto; padding: 0px;
position: relative;

This works fine on most browsers - the content sits centrally. However, on IE5 it sits at the left. Is my method only supported by IE 6 and above? If so, is there another way to achieve the same result on IE5?

pcthug
03-01-2006, 07:21 AM
Yes, it is a common IE5 bug.
To fix simply:
body {
text-align: center /* Required to center the Page */
}
#SomeDiv {
text-align: left; /* Is set to left align the content again */
margin: 0 auto;
}

derekjackson
03-01-2006, 09:20 AM
Seems to do the job fine - cheers! So how does it work?! The thing is being controlled by where the text sits?! Seems a little random!!

felgall
03-01-2006, 02:51 PM
IE5 requires text-align:center to center the block and ignores the margin:auto
All browsers need the text-align:left to put the text back where it belongs within the block.