The HTML Table Caption element (<caption>
) specifies the caption (or title) of a table, and if used is always the first child of a <table>
. Its styling and physical position relative to the table may be changed using the CSS caption-size
and text-align
properties.
Content categories | None. |
---|---|
Permitted content | Flow content. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | A <table> element, as its first descendant. |
Permitted ARIA roles | None |
DOM interface | HTMLTableCaptionElement |
Attributes
This element includes the global attributes.
Obsolete attributes
The following attributes are obsolete and should not be used. They are documented below for reference when updating existing code and for historical interest only.
align
- This enumerated attribute indicates how the caption must be aligned with respect to the table. It may have one of the following values:
left
- The caption is displayed to the left of the table.
top
- The caption is displayed above the table.
right
- The caption is displayed to the right of the table.
bottom
- The caption is displayed below the table.
Usage note: Do not use this attribute, as it has been deprecated: the<caption>
element should be styled using the CSS propertiescaption-side
andtext-align
.
Usage notes
When the <table>
element that is the parent of this <caption>
is the only descendant of a <figure>
element, you should use the <figcaption>
element instead of <caption>
.
Examples
Table With Caption
<table> <caption
>Example Caption</caption> <tr> <th>Login</th> <th>Email</th> </tr> <tr> <td>user1</td> <td>user1@sample.com</td> </tr> <tr> <td>user2</td> <td>user2@sample.com</td> </tr> </table>
caption { caption-side: top; align: right; } table { border-collapse: collapse; border-spacing: 0px; } table, th, td { border: 1px solid black; }
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<caption>' in that specification. |
Living Standard | |
HTML5 The definition of '<caption>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<caption>' in that specification. |
Recommendation |
Browser compatibility
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
align | Yes | Yes | 1 | Yes | Yes | Yes |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
align | Yes | Yes | Yes | 4 | Yes | Yes | Yes |