Tables
Basic table tags
<table> </table>
A table must be enclosed in a pair of <table> </table> tags.
The border attribute specifies the width in
pixels of the border lines around each cell. If you omit the
border attribute, no border lines are displayed.
For example: <table border="2">
<tr> </tr>
Each table row of a table is enclosed in a pair of <tr> </tr> tags.
The number of these pairs determines the number of rows in the
table. To remember what this tag does, think "tr means table row."
<td> </td>
Each cell in a row is enclosed in a pair of <td></td> tags.
For example, if you have 3 items in a table row, you will have
3 pairs of <td></td> tags. Think "td means table data," the
information in one cell of one row.
<th> </th>
You can have headings for your columns by enclosing
each heading cell in a pair of <th> </th> tags. The
text in these cells is bold and centered in the cell. Think "th
means table heading."
Here's a sample table with three rows, borders around each
cell and column headings:
| Name |
phone |
email |
| Richard |
555-6677 |
rmnixon@school.edu |
| Warren |
888-3535 |
wzweig@school.edu |
Cellpadding
The table above is a little crowded, but you can add the table
tag's cellpadding attribute to open it up a bit:
<table border cellpadding=5>
The resulting table will have a space 5 pixels wide between the
cell contents and the borders:
| Name |
phone |
email |
| Richard |
555-6677 |
rmnixon@school.edu |
| Warren |
888-3535 |
wzweig@school.edu |
It's tagged like this:
<table border cellpadding=5>
<tr>
<th>Name</th> <th>phone</th> <th>email</th>
</tr>
<tr>
<td>Richard</td> <td>555-6677</td> <td>rmnixon@school.edu</td>
</tr>
<tr>
<td>Warren</td> <td>888-3535</td> <td>wzweig@school.edu</td>
</tr>
</table>
If you need to do something more complex, see Netscape's Table
tutorial and Table
Sampler.
Last modified
July 20, 2004
by cawalker
|