<figcaption>: figure 的标题元素

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

<figcaption> HTML 元素代表其父级 <figure> 元素内容的标题或说明,为 <figure> 提供了一个 可访问名称

试一试

<figure>
  <img
    src="/shared-assets/images/examples/elephant.jpg"
    alt="Elephant at sunset" />
  <figcaption>An elephant at sunset</figcaption>
</figure>
figure {
  border: thin silver solid;
  display: flex;
  flex-flow: column;
  padding: 5px;
  max-width: 220px;
  margin: auto;
}

img {
  max-width: 220px;
  max-height: 150px;
}

figcaption {
  background-color: #222222;
  color: white;
  font: italic smaller sans-serif;
  padding: 3px;
  text-align: center;
}

属性

此元素仅包含全局属性

示例

有关 <figcaption> 的示例,请参阅 <figure> 页面。

技术摘要

内容类别 无。
允许内容 流内容.
标签省略 无,起始标签和结束标签都必须存在。
允许父级 一个 <figure> 元素; <figcaption> 元素必须是其第一个或最后一个子元素。
隐式 ARIA 角色 没有对应的角色
允许的 ARIA 角色 group, none, presentation
DOM 接口 HTMLElement

规范

规范
HTML
# the-figcaption-element

浏览器兼容性

另见

  • <figure> 元素。