[thelist] Centering a div with CSS

Michael Barrett mbarrett at triad.rr.com
Thu Jun 13 18:36:00 CDT 2002


> Try left:auto; right:auto;

If the DIV is not absolutely positioned...

The technically correct thing to do is:

    margin-left: auto;
    margin-right: auto;

As this should create equal margins on either side, centering the element
horizontally.

Not all browsers will comply with this however (Windows IE in particular)

You can style the containing element (the body, another DIV, whatever) of
the DIV you want to center like so:

    text-align: center;

Which should center the DIV in Win IE

--
Michael Barrett
-O^O-
  -

mbarrett at triad.rr.com




More information about the thelist mailing list