#1
  1. No Profile Picture
    Give peace a chance.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Buenos Aires, Argentina
    Posts
    83
    Rep Power
    15

    Question simple problem with tables and CSS


    It's a simple problem, how do I center a table with CSS ?
    Thank you.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Baltimore, MD, USA
    Posts
    5
    Rep Power
    0
    IIRC... you can wrap it in a div or span with a class that has align: center;

    Don't have access to my stylesheet here at work, but I know I went through the same problem a week ago when I transfered my normal HTML to XHTML (well, almost )
  4. #3
  5. No Profile Picture
    Give peace a chance.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Buenos Aires, Argentina
    Posts
    83
    Rep Power
    15

    Unhappy didn't work


    I tryed with align and text-align to center; in the table or a surrounding div and didn't work, if anybody is sure about this, please, tell me, maybe I did something wrong.
    If someone has to do it, I would like to do it in the table (without the surronding div), but anything that works will work (if it's XHTML 1.1/CSS).
    Thank you.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Baltimore, MD, USA
    Posts
    5
    Rep Power
    0
    Code:
    table { margin-right: auto; margin-left: auto }
    However, I have had some difficulty in getting it to work in IE5 and NN4.5. What does seem to work is to use the same CSS properties and values with DIV. Such as...

    PS... I got this to work in IE6 with the html loose, transitional, and strict doctype, but without a doctype declaration, it would not center the table in IE6.
    Last edited by etm117; July 15th, 2002 at 04:08 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Since tables aren't necessarily text, they tend not to obey the text-align member of defined classes in some browsers. I find the only sure fire solution is to stick to good old html <center></center> tags and not worry about css for that one.

IMN logo majestic logo threadwatch logo seochat tools logo