简介
HTML <caption> 元素 (or HTML 表格标题元素) 展示一个表格的标题,它常常作为 table 的第一个子元素出现,同时显示在表格内容的最前面,但是,它同样可以被 CSS 样式化,所以,它同样可以出现在任何一个一个相对于表格的做任意位置。
<table class="properties"> <tbody> <tr> <th scope="row"><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories">Content categories</a></th> <td>None.</td> </tr> <tr> <th scope="row">Permitted content</th> <td><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Flow_content">Flow content</a>.</td> </tr> <tr> <th scope="row">标签省略</th> <td>不允许,开始标签和结束标签都不能省略。</td> </tr> <tr> <th scope="row">Permitted parent elements</th> <td>A table element, as its first descendant.</td> </tr> <tr> <th scope="row">DOM interface</th> <td>HTMLTableCaptionElement</td> </tr> </tbody> </table>
特性
本元素包含了所有 全局特性。
align
使用说明
当 table 元素是caption 的父元素,caption 是figure 元素的唯一后代的时候,使用figcaption元素替代 caption 元素
实例
请查看 table 页面获得 caption的例子
Specifications
Browser compatibility
See also
- 其他与 table 相关的 HTML 元素:col, colgroup, table, tbody, td, tfoot, th, thead, tr;
- 可能对caption 元素有用的 CSS 属性:
- text-align, caption-side.
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
