#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2006
    Posts
    149
    Rep Power
    15

    Question Div in internet explorer


    i have a div on a page that i want to be centered. i am using in css as
    Code:
    margin: 0 auto
    that works fine and is centered in firefox, but is left aligned in internet explorer.
    how to accompalish it in iexplorer ??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    160
    Rep Power
    38
    Do you use a complete doctype?
    Is it for IE 5.x or ie6+?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2006
    Posts
    149
    Rep Power
    15
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
    <head>
    ......
    given above is the start of the page.

    and this problem is in internet explorers before iexplore 7.0.
    In iexplore 7.0, this problem has been eliminated.
  6. #4
  7. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4309
    Remove the XML declaration (shown in the code block below). It forces IE6 into quirks mode, which is usually a bad hting.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    If you wan to center it in IE5.x/Win as well check out Four ways to Center Elements with CSS (in IE5+/Win and other browsers).
    Spreading knowledge, one newbie at a time.

    Learn CSS. | PHP includes | HTML Validator | CSS validator

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2006
    Posts
    149
    Rep Power
    15
    thanks a lot man.

    removing that line solved my problem

IMN logo majestic logo threadwatch logo seochat tools logo