8.1 Using Tables on Web Pages^313
Notice how the table is described row by row. Also, each row is described cell by cell.
This attention to detail is crucial to the successful use of tables.
What if you don’t want a border on your table? The borderattributeis optional. The
table shown in Figure 8.1 uses a border with its width set to 1. If you omit the border
attribute, the table displays with no visible border. Figure 8.2 shows the same table with
the borderattribute omitted.
Figure 8.2
Table with no visible
border
Figure 8.3
Using
a table
XHTML Table Headings
The <th>, or table heading, element can be used to distinguish column headings from
table content. Figure 8.3 shows a table that uses the <th>element.
The XHTML for the table shown in Figure 8.3 is shown below. Notice that the first
row uses <th>instead of <td>tags.
<table border="1">
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Phone</th>
<th>E-mail</th>
</tr>
<tr>
<td>Jack</td>
<td>5/13</td>
<td>857-555-5555</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Sparky</td>
<td>11/28</td>
<td>303-555-5555</td>
<td>[email protected]</td>
</tr>
</table>
XHTML Table Captions
The <caption>element is often used with a data table to describe its contents. The
table shown in Figure 8.4 uses <caption>tags to set the caption to Birthday List.