Tables: HTML
The Basic Table

To create a table using HTML:
  • Use the <TABLE></TABLE> tag pair to mark the beginning and the end of the table.
  • Use the <TR></TR> tag pair to mark each table row.
NOTE: TR stands for Table Row
  • Use the <TD></TD> tag pair within each set of <TR></TR> tags to indicate the number of columns in each row.
  • Enter the data you want to appear in a table cell between the <TD> tags.
NOTE: TD stands for Table Data
  • If you wish to put a headline on your table, use the <TH></TH> tag pair just beneath the opening <TABLE> tag.
NOTE: TH stands for Table Header
Example Thus if I want to create a simple table with two rows and five columns, the HTML would be:

<TABLE BORDER=3>

<TR>
<TD>Mon </TD>
<TD>Tue </TD>
<TD> Wed</TD>
<TD>Thu </TD>
<TD>Fri </TD>
</TR>

<TR>
<TD>Off </TD>
<TD>Office </TD>
<TD>Office </TD>
<TD> Field</TD>
<TD> Off</TD>
</TR>

</TABLE>

Here is the table resulting from the above code:
Mon Tue Wed Thu Fri
Off Office Office Field Off
Align the Table You can center the table on the screen by placing the <CENTER></CENTER> tags before and after the <TABLE></TABLE> tags.
Adjust the Width and Border To adjust the width of the table on the screen, use the attribute WIDTH="%" where % is the per cent of the screen width taken up by the table.

To change the size of the border around the table use BORDER="n" where "n" is the width in pixels.

To create a borderless table set the value of n to 0.

In the table below the width of the table has been adjusted and the border has been increased.

<TABLE WIDTH=55% BORDER=5>

Mon Tue Wed Thu Fri
Off Office Office Field Off
Adjust the Space Between Cells To change the amount of space (in pixels) between table columns, use the CELLSPACING="n" attribute in the initial <TABLE> tag.

Here is our table with the CELLSPACING tag:

<TABLE WIDTH=55% CELLSPACING=3 BORDER=3>

Mon Tue Wed Thu Fri
Off Office Office Field Off
Adjust the Space Within Cells To change the amount of space (in pixels) between the cell data and the cell walls, use the CELLPADDING="n" attribute in the initial <TABLE> tag.

Here is our table with the CELLPADDING tag:

<TABLE WIDTH=55% CELLPADDING=3 BORDER=3>

Mon Tue Wed Thu Fri
Off Office Office Field Off

Tables: HTML
Overview
The Basic Table
Table Cell Attributes
Advanced Table Design

 

Personal Home PageWeb Design CenterTutorial MenuTop of Page

Web Design Center
Last Revised: October 19, 2006
© Agatha Taormina