HTML Tutorial: Tables
 

 

Here's our simple table again. 

The Planets

Mercury Mars
Jupiter Saturn

It still doesn't look like a real table, so lets do some formatting

The Planets

Mercury Mars
Jupiter Saturn
 

Well that looks a lot better - here's what I did:

<TABLE BORDER="2">
  <TR>
    <TD ALIGN="CENTER">Mercury</TD>
    <TD ALIGN="CENTER">Mars</TD>
  </TR>
  <TR>
    <TD ALIGN="CENTER">Jupiter</TD>
    <TD ALIGN="CENTER">Saturn</TD>
  </TR>
</TABLE>


The BORDER attribute: This tells the table how large the border should be. Every table has a border, but if you don't specify the size, then by default it is 0 - so you don't see it.

The ALIGN="CENTER" attribute in the <TD> tab tells the browser to align the text in the center of the cell. Try experimenting with ALIGN="left" and ALIGN="right".

Try it out yourself in the box below .....

Have a look at cellspacing and cellpadding to see what else you can do to your table.