THE WORLD'S LARGEST WEB DEVELOPER SITE

Table caption Property

❮ Table Object

Example

Alert the text inside a caption element:

alert(document.getElementById("myTable").caption.innerHTML);
Try it Yourself »

Definition and Usage

The caption property returns the <caption> element of a table.

The <caption> element defines a caption for a table.

Note: The <caption> tag must be inserted immediately after the <table> tag. You can specify only one caption per table. By default, the caption will be centered above the table.


Browser Support

Property
caption Yes Yes Yes Yes Yes

Syntax

tableObject.caption

Technical Details

Return Value: The <caption> element of the table, or null if it is not defined

Related Pages

HTML reference: HTML <caption> tag


❮ Table Object