HTML5中的多个<figcaption>在<figure>中

Ini*_*igo 7 html5

我想知道一个figure元素是否可以包含多个figcaption子元素?

我在某个地方读了一些东西(对不起,现在我找不到了),这似乎表明它无法 - 但我确信它figure可以包含多个img,所以这似乎是不合逻辑的.

如果我有两个相关的图像,我想要单独的标题怎么办?

Her*_*lek 18

您可以将img加号嵌套figcaption到多个图形标记中.要向代码添加更多语义,可以添加ARIA role属性.

<figure role="group">
    <figcaption>Caption for the whole group of images</figcaption>

    <figure>
        <img src="picture1.jpg" alt="Description of picture 1">
        <figcaption>Caption for Picture 1</figcaption>
    </figure>

    <figure>
        <img src="picture2.jpg" alt="Description of picture 2">
        <figcaption>Caption for Picture 2</figcaption>
    </figure>

</figure>
Run Code Online (Sandbox Code Playgroud)

  • "在无花果中"?我没有在代码中看到一个fig figure中的数字......一切似乎都对我有用. (2认同)