HTML and CSS Reference
In-Depth Information
Example 2.19: HTML markup for a simple table
(continued)
</tr>
<tr>
<th>
kitchen
</th> <td>
23
</td> <td>
30
</td>
</tr>
<tr>
<th>
dining room
</th> <td>
31
</td> <td>
45
</td>
</tr>
</table>
</body>
</html>
Figure 2.19: A simple table
For the table displayed in Figure 2.19, it is important to note the following.
First, the table is only as wide as it needs to be. Second, the caption is centered
above the table because that is where table captions are placed by default, not
because the
caption
element appears before the table rows. To place the caption
below the table, add the attribute
align
with the value bottom to the
caption
element. Finally, no grid lines indicate the table's borders and cells. Grid lines
are a function of the border attribute speciied in the table tag and any CSS
border properties assigned to the table's elements.
he
table
element has optional subelements for marking up logical groups
of rows. he
table head
element (
<thead></thead>
),
table foot
element
(
<tfoot></tfoot>
), and
table body
element (
<tbody></tbody>
), can each
contain zero or more table row elements. A table can have many table body
elements but no more than one table head and one table foot element. Com-
bining these factors, the model for a table follows this form: