Align DIV Center

Discussion in 'CSS' started by whirlybird20, Jul 15, 2008.

  1. #1
    I have been aligning my divs to the center using "margin-left:auto;" and "margin-right:auto;", but then I found that this doesn't work in internet explorer 6. Does anyone know how to overcome this problem?
     
    whirlybird20, Jul 15, 2008 IP
  2. yankzilla

    yankzilla Peon

    Messages:
    159
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just add:
    body {text-align: center;}
    Code (markup):
     
    yankzilla, Jul 15, 2008 IP
  3. whirlybird20

    whirlybird20 Guest

    Messages:
    462
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks. That works great!
     
    whirlybird20, Jul 16, 2008 IP
  4. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #4
    Add this code on the top of your page:
     
    srobona, Jul 16, 2008 IP
  5. js09

    js09 Peon

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    don't forget about position:relative
     
    js09, Jul 17, 2008 IP
  6. garyc40

    garyc40 Peon

    Messages:
    115
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You don't have to use text-align. Just add the DOCTYPE to the top of the document as srobona said. Without it ie will render the page in quirk mode, which throws everything in chaos.
     
    garyc40, Jul 18, 2008 IP