HTML <caption> tag

Updated: 09/12/2023 by Computer Hope
HTML caption tag

When writing in HTML (hypertext markup language), the <caption> tag is a block element used to add a title to a table. The following sections contain information about the <caption> tag, including an example of it in use, and related attributes and browser compatibility.

Note

If you are using the <caption> tag inside of a <table> tag that is the only element in a <figure>, use <figcaption> instead.

Example of <caption> code

<table class="mtable2 tab">
<caption>I'm a Table Caption</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr class="tcw">
<td>March</td>
<td>$200</td>
</tr>
<tr class="tcw">
<td>April</td>
<td>$300</td>
</tr> <tr class="tcw">
<td>May</td>
<td>$250</td>
</tr>
</table>

Example result

I'm a Table Caption
Month Savings
March $200
April $300
May $250

As you can see in the previous example, there is a title above the table; it was put there using the <caption> tag. We have also used CSS (cascading style sheets) to added classes to the table and its rows to make them look nicer.

Deprecated attributes

All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <caption> tag had the following unique attributes that are now deprecated.

Attribute Description
align Designated the alignment of the table caption.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Compatibility, Container tag, Parent and child, Title, Web design terms