Best way to center a div?

Discussion in 'CSS' started by Amsterdam, May 20, 2006.

  1. #1
    Apologies if this has been asked before, but...

    What is the best way to center a wrapper div in XHTML 1.0? Are there any neat solutions compatible with all browsers?

    T
     
    Amsterdam, May 20, 2006 IP
  2. spainexpat

    spainexpat Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try:

    body {
    margin: 0 auto;
    }
     
    spainexpat, May 20, 2006 IP
    Amsterdam likes this.
  3. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Sorry, but that doesn't work.

    T
     
    Amsterdam, May 20, 2006 IP
  4. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Please accept my apologies! It DOES work, but it has to be specified for the div and not the body.

    Thanks!

    T
     
    Amsterdam, May 20, 2006 IP
  5. spainexpat

    spainexpat Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ah, right, good stuff then. That was going to be my next suggestion if it didn't work. :)
     
    spainexpat, May 21, 2006 IP