#1
  1. No Profile Picture
    hitokiri battousai
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    38
    Rep Power
    12

    center align table on page with CSS


    how do i center align table on page with CSS?
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Italy, EU
    Posts
    517
    Rep Power
    12
    Put the table in a paragraph and apply CSS to this element:
    <p style="text-align:center">
    Cheers, Dave
  4. #3
  5. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    Originally posted by magma
    Put the table in a paragraph and apply CSS to this element:
    <p style="text-align:center">
    wrong, p-tags cannot contain block-level elements,

    and the correct way to center an element with css is to use :

    .myTable {
    margin-left:auto;
    margin-right:auto;
    }

    but ofcourse msie doesn't complay with this, so you have to assign text-align:center in the parent element.

    ie
    body {
    text-align:center;
    }

    or place a div-tag around the table,
    with style="text-align:center" as magma suggested

IMN logo majestic logo threadwatch logo seochat tools logo