Table caption 属性

定义和用法

caption 属性返回表格的 <caption> 元素。

<caption> 元素定义表格的标题。

注意:<caption> 标签必须紧跟在 <table> 标签之后。您只能为每个表格规定一个标题。默认情况下,标题将在表格上方居中。

另请参阅:

HTML 参考手册:HTML <caption> Tag

实例

提示标题元素内的文本:

alert(document.getElementById("myTable").caption.innerHTML);

Try It Yourself

Syntax

tableObject.caption

Technical Details

Return Value: The <caption> element of the table, if undefined, is null.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support