<caption>
HTML <caption> (Table Caption) Tag
Example
<table>
<caption>User Name</caption>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
Meaning
The <caption> element is used within the table element to define a caption.
Notes:
- By default, a table caption will be center-aligned above a table. CSS properties text-align and caption-side can be used to align and place the caption.
- There should be only one caption per table.
Version: HTML 3.2, 4, 4.01, 5
Standard Syntax
<caption>...</caption>
Advertisement
Global Attributes
<caption> element also supports the Global Attributes in HTML.
Event Attributes
<caption> element also supports the Event Attributes in HTML.
More Examples
Example
<table>
<caption style="text-align: left">User name</caption>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
<br>
<br>
<table>
<caption style="caption-side: bottom">User name</caption>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
By Default CSS Value(s)
Most of the browsers will display the <caption> element with the following by default value(s)
caption {
display: table-caption;
text-align: center;
}
Related Tags:
<col>,
<colgroup>,
<table>,
<tbody>,
<td>,
<tfoot>,
<th>,
<thead> and
<tr>