AI教程网 - 未来以来,拥抱AI;新手入门,从AI教程网开始......

HTML5 caption 标签

HTML5教程 AI君 57℃

实例

HTML5 <caption>标签用来为表格定义一个标题,使用示例如下:

带有标题的表格:

<table border="1"> 
<caption>Monthly savings</caption> 
<tr> <th>Month</th> <th>Savings</th> </tr> 
<tr> <td>January</td> <td>$100</td> </tr>
</table>


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持 <caption> 标签。


标签定义及使用说明

<caption> 标签定义表格的标题。

<caption> 标签必须直接放置到 <table> 标签之后。

您只能对每个表格定义一个标题。

提示:通常这个标题会被居中于表格之上。然而,CSS 属性 “text-align” 和 “caption-side” 能用来设置标题的对齐方式和显示位置。


HTML 4.01 与 HTML5之间的差异

HTML5 不支持 align 属性。

HTML 4.01 已废弃 align 属性。


属性

属性 描述
align (已废弃) left
right
top
bottom
HTML5 不支持。HTML 4.01 已废弃。 定义标题的对齐方式。

使用说明: 当 <table> 元素是 <caption> 的父元素,caption是 <figure> 元素的唯一后代的时候,使用 <figcaption> 元素替代 caption 元素


全局属性

<caption> 标签支持 HTML 的全局属性


事件属性

<caption> 标签支持 HTML 的事件属性

转载请注明:www.ainoob.cn » HTML5 caption 标签

喜欢 (0)or分享 (0)