<caption>


HTML <caption> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<table border="1">
  <caption>Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>0</td>
  </tr>
  <tr>
    <td>February</td>
    <td></td>
  </tr>
</table>

</body>
</html>

Running Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

All major browsers support< caption> tag.


Tag definition and usage instructions

<caption> The tag defines the title of the table.

The<caption> tag must be placed directly after the <table> tag.

You can only define one title per table.

Tip: Usually this title will be centered above the table. However, the CSS property "text-align" and "caption-side" can be used to set the alignment and display position of the title.


Differences between HTML 4.01 and HTML5

HTML5 does not support the align attribute.

The align attribute has been deprecated in HTML 4.01.


Properties

PropertiesValueDescription
alignleft
right
top
Bottom
HTML5 is not supported. HTML 4.01 is deprecated. Define the alignment of the title.


Global attributes

<caption> tag supports global attributes of HTML.


Event attributes

<caption> tag supports HTML event attributes.