此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
<figcaption>:圖例說明元素
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 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 #c0c0c0 solid;
display: flex;
flex-flow: column;
padding: 5px;
max-width: 220px;
margin: auto;
}
img {
max-width: 220px;
max-height: 150px;
}
figcaption {
background-color: #222;
color: #fff;
font: italic smaller sans-serif;
padding: 3px;
text-align: center;
}
屬性
該元素僅包括全域屬性。
範例
請參見 <figure> 頁面上 <figcaption> 的範例。
技術摘要
| 內容類型 | 無。 |
|---|---|
| 允許內容 | 流內容。 |
| 標籤省略 | 不允許,開始和結束標籤都是必須的。 |
| 允許的父元素 |
一個 <figure> 元素;<figcaption> 元素必須是其第一個或最後一個子元素。
|
| 隱含的 ARIA 角色 | 沒有相對應的角色 |
| 允許的 ARIA 角色 |
group、none、presentation
|
| DOM 介面 | HTMLElement |
規範
| Specification |
|---|
| HTML> # the-figcaption-element> |
瀏覽器相容性
Loading...
參見
<figure>元素。