Chapter 4: The Basic Table Tags
A table requires at least three HTML tags, as follows:
- The <table> tag defines the table itself.
- Within the <table> tag there will be one <tr> tag for each row.
- Within each <tr> tag there will be one <td> tag for each cell, or column.
- Within each <td> tag you place the content for that cell.
The following
HTML creates a basic table with two rows and two
columns; the resulting table is shown in Figure 4-2. Note that I have
included the border attribute, which I'll get to later in the chapter. You
can omit this but then the table would display without borders, which
would not have been appropriate for this example.
<body>
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
</body>
Figure 4-2. A simple two row, two column table.
Most of the remainder of this chapter is devoted to showing you how to
modify this basic table to get exactly what you want.