Results 1 to 4 of 4

Thread: horizontally align (css2 & xhtml strict compliant)

  1. #1

    Thread Starter
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294

    horizontally align (css2 & xhtml strict compliant)

    Hey all,

    I was wondering how i could align a table horizontally centered while still being css2 and xhtml strict compliant. I know so far the setting the right and left margins to auto will work, but it doesnt work in some browsers. Does anyone know of a more accepted way of doing it?

    thanks

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I think this should work:

    Code:
    <div style="text-align:center;">
      <table width="50%" style="border:1px solid black; margin:0px auto; text-align:left;">
        <tr><td>asdasd</td></tr>
      </table>
    </div>
    The first text-align makes IE center the block elements (i.e. the table), which it shouldn't do. And the second one makes the other browsers put the inline elements in the table back to where they should be. (The width and the border are just to emphasis the effect.)

  3. #3

    Thread Starter
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    You're the man

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width