series

To Center a CSS Table

  1. add a 'center class' with the margin to auto:
  2. .center{margin:auto;}
  3. add an id to the table
  4. #table1, th, td {
    width:50px;
    border: 1px solid black;
    border-spacing:20px;padding:20px;
    }
  5. start the table like this
  6. <table id="table1" class="center">
It is best to write each table element on its own line
when trying to center multiple tables.
Firstname Lastname Age
Jill Smith 50
Eve Jackson 94
#table1 { width:50px; border: 1px solid black; border-spacing:20px;padding:20px; }
#table1 th { width:50px; border: 1px solid black; border-spacing:20px;padding:20px; }
#table1 td { width:50px; border: 1px solid black; border-spacing:20px;padding:20px; }

home Valid CSS! HTML Hit Counter