HTML <caption> tag

Updated: 11/13/2018 by Computer Hope
HTML caption tag

When writing in HTML, the <caption> tag is a block element used to add a title to a table. It should be noted that if you are using the <caption> tag inside of a <table> tag that is the only element in a <figure>, use <figcaption> instead. The following sections contain information about the <caption> tag, including an example of it in use, as well as related attributes and browser compatibility.

Example of <capation> code

<table class="mtable2 tab">
<caption>I'm a Table Caption</caption>
<tr class="tcw">
<tr class="tcw">
</tr> <tr class="tcw">

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 to added classes to the table and its rows to make them look nicer.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The <caption> tag only has one unique attribute that became deprecated and the obsolete within HTML5. The following table shows that attribute, as well as a description of what it did.

Attribute Description
align Designated the alignment of the table caption.


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

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