表标题属性返回表的
元素,该元素用于定义表的标题。只能将一个标题分配给一个表,并且在元素内输入的标题默认为居中对齐。
用法
tableObject.caption
以下示例程序旨在说明表caption()属性:
例:提示标题元素内的文本。
Table caption Property in HTML
table,
td {
border:1px solid green;
}
h1 {
color:green;
}
h2 {
font-family:Impact;
}
body {
text-align:center;
}
GeeksforGeeks
Table caption Property
To return the caption element
for the table, double-click the
"Return Caption" button.
SubjectCourses
JavaFork JavaPythonFork PythonPlacementsSudo Placement
Return Caption
function Table_Caption() {
// Return caption using alert.
alert(document.getElementById(
"Courses").caption.innerHTML);
}
输出:
在单击按钮之前:
单击按钮后:
支持的浏览器:
苹果Safari
IE浏览器
Firefox
谷歌浏览器
Opera