HTML <caption> tag
The <caption> tag in HTML defines a caption for the table.
Ideally, you should code only one caption per table.
Syntax:
<caption>Table Name</caption>
Example
<table width ="30%" border ="4"> <caption>TutorialBrain Courses</caption> <tr> <th>BIG DATA </th> <th>MAINFRAME </th> </tr> <tr> <td>Spark</td> <td>COBOL</td> </tr> <tr> <td>Scala</td> <td>DB2</td> </tr> </table>
Default CSS Values
display: table-caption;
text-align: center;
How Browser will display
INLINE.
Difference between HTML4.01, XHTML and HTML5
HTML4 | XHTML | HTML5 |
---|---|---|
None | None | The align attribute is deprecated from <caption> tag |
Attributes used with <caption> tag
Attribute | Description |
---|---|
align | To align the caption of the table to left, right, top, or bottom. (HTML5 does not support this attribute when it is used with the <caption> tag). |
Note/Info By default, the caption of the table will aligned to the center. To change this, you can use CSS Align property along with the caption-side property.
Global Attributes
The <caption> tag supports Global attributes.
Event Attributes
The <caption> tag supports Event attributes.
Supporting Browsers
Related Tags
<caption>, <th>, <tr>, <td> tags.