<figcaption>
标签表示图像的标题或说明。它是与 <figure>
元素一起使用的,其中 <figure>
元素用于组合媒体内容及其标题。
<figcaption>
元素可以具有以下属性:
align
: 规定如何对齐 <figcaption>
元素。此属性已被废弃,不应再使用。class
: 规定元素的类名(类似于 CSS 中的 class 选择器)。id
: 规定元素的唯一 ID。style
: 规定元素的行内样式(例如,color、font-size、border 等)。title
: 规定关于元素的额外信息。示例代码:
<figure>
<img src="image.jpg" alt="Image">
<figcaption class="caption" id="fig1" style="color: blue;" title="This is a caption">This is a caption</figcaption>
</figure>
在上面的示例中,<figcaption>
元素具有 class
属性,其值为 caption
,因此可以通过 CSS 样式表来设置元素的样式。<figcaption>
元素还具有 id
属性,其值为 fig1
,可以用于 JavaScript 代码中的 DOM 操作。<figcaption>
元素还具有 style
属性,其值为 color: blue;
,它将设置 <figcaption>
元素的文本颜色为蓝色。<figcaption>
元素还具有 title
属性,其值为 This is a caption
,它将在用户将鼠标悬停在元素上时显示一段额外信息。