HTML <caption> tag
The <caption> tag is used to create a table caption. Captions appear at the top of a table by default.
NOTE: The <caption> tag should be placed right below the <table> tag before the first <tr> tag.
Attributes
| Attribute | Possible values | Description |
|---|---|---|
| align | left, right, top, bottom | Deprecated. Sets how a caption will be aligned |
Firefox is the only one of the major browsers that properly supports the align attribute. All the major browsers support top and bottom alignment of a caption, left and right alignment of a caption is not supported at all in Chrome or Safari, and only the text inside the caption (as opposed to the entire caption element) is aligned in Internet Explorer and Opera.
Standard attributes
class, dir, id, lang, style, title, xml:lang
For more information on standard attributes, check out our HTML standard attributes reference page.
Event attributes
onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup
For more information on event attributes, check out our HTML event attributes reference page.
Example
NOTE: The below example will appear correctly only in Firefox
| Month | Total |
|---|---|
| January | 1000 |
| February | 1200 |
Tips & notes
Having a caption for a table is a good usability practice - it makes your content look more organized. But be sure to style the caption to distinguish it from other elements on a page.