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-side
and text-align
properties.
Content categories | None. |
---|---|
Permitted content | Flow content. |
Tag omission | The end tag can be omitted if the element is not immediately followed by ASCII whitespace or a comment. |
Permitted parents | A <table> element, as its first descendant. |
Permitted ARIA roles | None |
DOM interface | HTMLTableCaptionElement |
This element includes the global 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
left
top
right
bottom
<caption>
element should be styled using the CSS properties caption-side
and text-align
.When the <table>
element that contains the <caption>
is the only descendant of a <figure>
element, you should use the <figcaption>
element instead of <caption>
.
This simple example presents a table that includes a caption.
<table> <caption>Example Caption</caption> <tr> <th>Login</th> <th>Email</th> </tr> <tr> <td>user1</td> <td>[email protected]</td> </tr> <tr> <td>user2</td> <td>[email protected]</td> </tr> </table>
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 |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
align
|
Yes | Yes | 1 | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
align
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
<col>
, <colgroup>
, <table>
, <tbody>
, <td>
, <tfoot>
, <th>
, <thead>
, <tr>
;<caption>
element:
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption