centering in ie

Discussion in 'CSS' started by ronie_imaginet, Jun 4, 2008.

  1. #1
    Hi! i made a web page, but i can't center it, i already used the "margin:0px auto" but it didn't work, but in FF it did..

    can anyone help me with this?

    thanks

    ronie:)
     
    ronie_imaginet, Jun 4, 2008 IP
  2. rochow

    rochow Notable Member

    Messages:
    3,991
    Likes Received:
    245
    Best Answers:
    0
    Trophy Points:
    240
    #2
    Ensure you have set a width on the same element you are centering.
     
    rochow, Jun 4, 2008 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    ... and there's the tell.

    If margin:auto is not working in JUST Internet Exploder, it means you are in quirks mode, most likely from having an invalid/malformed/nonexistant doctype, or including an XML prolog before the doctype. It also likely means much of your CSS is likely hacking around quirks mode behavior instead of being standards compliant.

    If you post a link or your code, we can likely ACTUALLY help you. Asking for help without showing us your code is pointless.
     
    deathshadow, Jun 4, 2008 IP
  4. Smeey

    Smeey Well-Known Member

    Messages:
    377
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #4
    <div align="center">Content</div>
     
    Smeey, Jun 4, 2008 IP
  5. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Smeey your code might do the trick but it's depreceated, uses an extra DIV for no reason, teaches newbies the wrong thing and was probably the correct answer about 10 years ago.
     
    wd_2k6, Jun 4, 2008 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Though adding text-align:center; to the body might make quirks mode IE work - I usually include it so IE5 (which has no standards mode) will attempt to work.

    But yeah, align==/FAIL/. Total and miserable /FAIL/. "You got your presentation in my markup" - unfortunately this is NOT PB + Chocolate.
     
    deathshadow, Jun 4, 2008 IP
  7. ronie_imaginet

    ronie_imaginet Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks guys, i already solved my problem.

    i used text-align:center
     
    ronie_imaginet, Jun 4, 2008 IP
  8. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #8
    You didn't solve the problem, you just covered it up by writing bad code to accommodate a buggy browser.

    Did you not read deathshadow's posts? That is the wrong way to do things. The only thing you need to do is trigger standards mode.

    If you're not willing to code to standards, you will continue to have all sorts of x-browser compatibility issues.

    gary
     
    kk5st, Jun 4, 2008 IP
  9. rochow

    rochow Notable Member

    Messages:
    3,991
    Likes Received:
    245
    Best Answers:
    0
    Trophy Points:
    240
    #9
    But why, that's all the rage today.

    Post asking for help, then ignore everyone that answers and just do whatever, even if its the wrong way of doing things.
     
    rochow, Jun 4, 2008 IP
  10. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Yeah it's often the case with the designer who is happy with his site that looks great on his resolution, with his browser. Until the day he logs onto his site from a different machine or different browser they won't care but when this day comes they come running back.
     
    wd_2k6, Jun 5, 2008 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #11
    Which is why I do not as a rule advocate 'silver bullet' fixes for bugs when there are larger underlying issues.

    Though in this case, we haven't even seen his code or the page in question, so none of us can REALLY say if it's inappropriate or not.
     
    deathshadow, Jun 5, 2008 IP
  12. ferman

    ferman Well-Known Member

    Messages:
    968
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    140
    #12
    the code works perfect too in I.E and F.F there must some other width property conflicting with it
     
    ferman, Jun 6, 2008 IP