Syntax | <caption>...</caption> |
---|---|
Attribute Specifications |
|
Contents | Inline elements |
Contained in | table |
The caption element defines a table caption. When used, caption must be the first element in the table. Only inline elements (e.g., strong) may be used within caption.
A good caption should provide a short heading for the table. For simple tables, the caption can also act as an adequate summary, but for more complex tables, authors should supplement the caption with a full summary, either through table's summary attribute or within a paragraph outside of the table. The following example features a simple table where the caption provides a heading and an adequate table summary:
<table>
<caption>Common Usenet Abbreviations</caption>
<thead>
<tr>
<th>Abbreviation</th>
<th>Long Form</th>
</tr>
</thead>
<tbody>
<tr>
<td>AFAIK</td>
<td>As Far As I Know</td>
</tr>
<tr>
<td>IMHO</td>
<td>In My Humble Opinion</td>
</tr>
<tr>
<td>OTOH</td>
<td>On The Other Hand</td>
</tr>
</tbody>
</table>
The next example uses table's summary attribute to complement the caption:
<table summary="This table gives the character entity reference,
decimal character reference, and hexadecimal character
reference for symbols and Greek letters.">
<caption>Symbols and Greek Letters in XHTML 1.0</caption>;
<colgroup>
<colgroup span="3">
<thead>
<tr>
<th scope="col">Character</th>
<th scope="col">Entity</th>
<th scope="col">Decimal</th>
<th scope="col">Hex</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row">Latin small f with hook</td>
<td>&fnof;</td>
<td>&#402;</td>
<td>&#x192;</td>
</tr>
...
</tbody>
</table>
The deprecated align attribute of caption specifies the alignment of the caption relative to the table. Possible values are top (the default), bottom, left, and right.