[thelist] Centering divs in CSS

Rob Schumann roblgs at cscoms.com
Fri Nov 8 01:21:49 CST 2002


Hi,

On 06-11-2002 Chris Evans wrote:

 >  > I would like to center a div using CSS.  Using
 >  > {margin-right: auto; margin-left: auto;} works in Mozilla,
 >  > but not IE6.
 >  >

To which Taranis wrote in response...

 > You can also do something like this:
 >
 > <div id="container">
 >  <div id="content">
 >  Content Here
 >  </div>
 > </div>
 >
 > And the styles are:
 > #container {
 >  text-align: center;
 > }
 > #content {
 >  text-align:left;
 > }

>From my own experience and a similar problem on IE6 a while back... the

{margin-right: auto; margin-left: auto;}

SHOULD work. At a guess you have an xml declaration at the top of your html document

<?xml version="1.0" encoding="iso-8859-1"?>

This will be causing IE6 to work like IE5, requiring the css hackery that Taranis responded with.

If working with IE5 isn't an issue and you are comfortable about doing away with the xml declaration, then removing it WILL make the auto left and right margins work as expected.

Best regards


Rob



More information about the thelist mailing list