HTML <caption> Element
The <caption> element defines a caption in an HTML table. The caption is defined immediately after the opening
<table> tag and should convey information about the contents of the table.
The default browser behaviour is to display the caption above the table in the center.
Example of the <caption> element in use:
<table>
<caption>INCOME FOR THE LAST 3 YEARS</caption>
<thead>
<tr>
<th>Year</th>
<th>Earnings</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Total</td>
<td>$25,000</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>2008</td>
<td>$12,000</td>
</tr>
<tr>
<td>2009</td>
<td>$3,000</td>
</tr>
<tr>
<td>2010</td>
<td>$10,000</td>
</tr>
</tbody>
</table>
<caption>INCOME FOR THE LAST 3 YEARS</caption>
<thead>
<tr>
<th>Year</th>
<th>Earnings</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Total</td>
<td>$25,000</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>2008</td>
<td>$12,000</td>
</tr>
<tr>
<td>2009</td>
<td>$3,000</td>
</tr>
<tr>
<td>2010</td>
<td>$10,000</td>
</tr>
</tbody>
</table>
Result:
| Year | Earnings |
|---|---|
| Total | $25,000 |
| 2008 | $12,000 |
| 2009 | $3,000 |
| 2010 | $10,000 |
<caption> Attributes
- CORE AND LANGUAGE ATTRIBUTES - class, id, title, style, dir, lang
- MOUSE AND KEYBOARD EVENT ATTRIBUTES - onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmouseout, onmousemove, onkeydown, onkeyup, onkeypress
HTML 4 Element List
<!--<comment>--><!DOCTYPE><a><abbr><acronym><address><applet><area><b><base><basefont><bdo><big><blockquote><body><br><button> <caption><center><cite><code><col><colgroup><dd><del><dfn><dir><div><dl><dt><em><fieldset><font><form><frame><frameset><head><h1> to <h6><hr><html><i><iframe><img><input><ins><isindex><kbd><label><legend><li><link><map><menu><meta><noframes><noscript><object><ol><optgroup><option><p><param><pre><q><s><samp><script><select><small><span><strike><strong><style><sub><sup><table><tbody><td><textarea><tfoot><th><thead><title><tr><tt><u><ul><var>
