<caption>

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

简介

HTML <caption> 元素 (or HTML 表格标题元素) 展示一个表格的标题,它常常作为 <table> 的第一个子元素出现,同时显示在表格内容的最前面,但是,它同样可以被 CSS 样式化,所以,它同样可以出现在任何一个一个相对于表格的做任意位置。

Content categories None.
Permitted content Flow content.
标签省略 不允许,开始标签和结束标签都不能省略。
Permitted parent elements A <table> element, as its first descendant.
DOM interface HTMLTableCaptionElement

特性

本元素包含了所有 全局特性

align 已弃用

这个可枚举属性表明了 caption 相对于 table 应该如何排列。它可能有以下几个值:

  • left, 展示在表格左边
  • top, 显示在表格前面
  • right, 显示在表格右边
  • bottom, 显示在表格下面

备注: 不要使用这个属性,它已经被弃用:<caption> 元素应该使用 CSS设置样式。要得到类似align属性的效果,使用 CSS 属性 caption-sidetext-align.

使用说明

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

实例

请查看 <table> 页面获得 <caption>的例子

Specifications

Specification
HTML
# the-caption-element

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
caption
align
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Deprecated. Not for use in new websites.

See also