English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML <caption> tag defines the table title in the HTML document. Traditionally, browsers render the text found in the <caption> tag at the top of the table, but you can use CSS caption-side attribute changes this behavior. This tag is also commonly referred to as the <caption> element.
The HTML <caption> element (or HTML table title element) displays a table title, which is often the first child of <table> and appears at the beginning of the table content, but it can also be styled with CSS, so it can appear at any position relative to the table.
Table with caption title:
!doctype html> <html> <head> <meta charset="UTF-8"> <title>Basic Tutorial Website(oldtoolbag.com)</title> </head> <body> <table> <caption>This is the caption for the table</caption> <tr> <th>Column 1 Heading</th> <th>Column 2 Heading</th> <th>Column 3 Heading</th> </tr> <tr> <td>Data in Column 1, Row 2</td> <td>Data in Column 2, Row 2</td> <td>Data in Column 3, Row 2</td> </tr> <tr> <td>Data in Column 1, Row 3</td> <td>Data in Column 2, Row 3</td> <td>Data in Column 3, Row 3</td> </tr> <tr> <td>Data in Column 1, Row 4</td> <td>Data in Column 2, Row 4</td> <td>Data in Column 3, Row 4</td> </tr> </table> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the <caption> tag.
The HTML <caption> element is located within the <body> tag.
The <caption> tag appears as the first tag after the <table> tag.
The <table> tag is composed of <tr>, <th>, and <td> tags.
Most browsers will display the <caption> tag above the table, but you can use CSS caption-The side attribute changes this behavior.
The <caption> tag defines the title of the table.
The <caption> tag must be placed directly after the <table> tag.
Note: Only one title can be specified for each table.
Tip: By default, the table title will be centered above the table. However, you can use CSS text-align and caption-side can be used for alignment and placement of the title.
The align attribute has been removed from HTML5Removed from HTML
Attribute | Value | Description |
---|---|---|
align | left right top bottom | HTML5 Not supported. HTML 4.01 Deprecated.
Defines the alignment of the title. |
Support for <caption> tag Global Attributes of HTML.
Support for <caption> tag HTML Event Attributes.