Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Table Attribute II

    How can i center align a <table> ?
    align="center" wont validate in xhtml10 strict

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To center a table..

    table {
    width:80%;
    margin:0px 10%;
    }



    Or:

    table {
    margin-left:auto;
    margin-right:auto;
    }



    But Win/IE5 doesn't understand 'auto'. You need a workaround:

    body {
    text-align:center;
    }

    table {
    margin-left:auto;
    margin-right:auto;
    text-align:left; /* to compensate for the text-align:center */
    }

  • #3
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by MCookie

    table {
    width:80%;
    margin:0px 10%;
    }
    thanks alot for the help, but whats the significance of having the width there?
    is this basically a method of not centering the table, but through margins and size, forcing it to the center?

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, it centers the table without centering it.. You could also use this:

    table {
    width:80%;
    margin:0px auto;
    }

    but Win/IE5 doesn't understand 'auto'. That's why I used the 10% margins.

  • #5
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok
    thanks alot man.
    xhtml strict can be tricky


  •  

    Posting Permissions

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