HTML <caption> Tag
Definition and Usage
<caption>
The <caption> tag defines a table title.
The <caption> tag must follow the <table> tag. You can only define one title for each table.
Tip:By default, the table title is centered above the table. However, the CSS properties text-align and caption-side can be used to align and position the title.
See also:
HTML DOM Reference Manual:Caption Object
Instance
Example 1
Table with Title:
<table> <caption>Monthly Savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>¥3000</td> </tr> </table>
Example 2
Table Title (using CSS):
<table> <caption style="text-align:right">My Savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>¥3000</td> </tr> </table> <br> <table> <caption style="caption-side:bottom">My Savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>¥3000</td> </tr> </table>
Global Attributes
<caption>
The tag also supports Global Attributes in HTML.
event attributes
<caption>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will display the following default values <caption>
Element:
caption { display: table-caption; text-align: center; }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |