The colspan attribute introduced on the last page is also useful
in making column headings.
But before we go into headings, let me show you a feature of tables
that I have been using so far without mentioning: the CAPTION.
In the following table, the caption appears in blue, and demonstrates the "BOTTOM" alignment.
- The caption tag is used inside the opening and closing
- The caption is NOT contained within a border.
- The alignment options are "TOP" (appears top/centered),
"LEFT" (appears top/left),
"RIGHT" (appears top/right),
and "BOTTOM" (appears centered underneath table).
- The default alignment of the caption is "TOP."
NOTE: the caption tag does not have a color attribute, and will normally
appear in the default font color unless you use other tags to modify it.
Table 7 Code
<table border=2 bgcolor=gray cellpadding=5>
<caption align=bottom>Growth Table</caption>
<th colspan=4>GROWTH PROJECTIONS</th>
<th> / </th>
<td> 0.20% </td>
<td> 0.45% </td>
<td> 0.80% </td>
<td> 1.20% </td>
<td> 1.80% </td>
<td> 2.01% </td>
In the code for the above table there are a number of new features; please note in particular
the <caption> tag and its align attribute.
Next, if I may draw your attention to the first table row (indicated by the first set of
tags), you will notice <th> tags have been used in place of <td>
In the "Growth Table" above, you can see I used the <th> tag combined
with the colspan attribute to give the main heading of "GROWTH PROJECTIONS" to the entire table
(though it wasn't really necessary in this particular case, since I also used the <caption>
tag). I also used the <th> tag to name the rows "U.S.A." and "Mexico" and to name the columns
"June," "July," & "Aug."
- <th> stands for "table heading."
- You can use the <th> tags anywhere you
would use <td> tags.
- The <th> tag makes the text BOLD and gives the text a