HTML Tag Reference - HTML tag <caption>








<caption> marks a short description to be added to a table. It may only be placed immediately after an opening <table> tag.

Browser compatibility

<caption> Yes Yes Yes Yes Yes

What's new in HTML5

The align attribute is removed from HTML5.

Attribute

align
Possible values:left|right|top|bottom. Not supported in HTML5. Defines the alignment of the caption.

Global Attributes

The <caption> tag supports the Global Attributes in HTML.





Event Attributes

The <caption> tag supports the Event Attributes in HTML.

Default CSS Settings

caption { 
    display: table-caption;
    text-align: center;
}

Example

A demo showing how to use <caption> tag.

<html>
<body>
          <table>
               <caption>This is the caption for this table.</caption>
               <tr>
                    <td>Cell 1</td>
                    <td>Cell 2</td>
               </tr>
               <tr>
                    <td>Cell 3</td>
                    <td>Cell 4</td>
               </tr>
          </table>
</body><!--from w ww  .  j a v  a2 s  .  co m-->
</html>

Click to view the demo