我想知道一个 figure
元素是否可以包含多个 figcaption
子元素?
我在某处读到过一些东西(抱歉,现在我找不到了),似乎表明它不能-但我确信一个 figure
可以包含多个 img
,所以那似乎是不合逻辑的。
如果我有两幅相关的并排图片,我想要单独的标题怎么办?
我想知道一个 figure
元素是否可以包含多个 figcaption
子元素?
我在某处读到过一些东西(抱歉,现在我找不到了),似乎表明它不能-但我确信一个 figure
可以包含多个 img
,所以那似乎是不合逻辑的。
如果我有两幅相关的并排图片,我想要单独的标题怎么办?
您可以将img
和其figcaption
嵌套到多个figure
标记中。为了使代码更具语义性,您可以添加一个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>
<figure>
<img>
<figure>
<figcaption></figcaption>
</figure>
<figcaption></figcaption>
</figure>
或者
<figure>
<figcaption></figcaption>
<img>
<figure>
<figcaption></figcaption>
</figure>
</figure>