HTML5 multiple <figcaption> inside <figure>

I would like to know if a figure element can contain more than one figcaption ?

I read something somewhere (sorry, now I can’t find it), which, it seems, can’t, but I’m sure that figure can contain more than one img , so this seems illogical.

What if I have two linked images side by side for which I want separate captions?

+5
source share
3 answers

You can insert img plus its figcaption into several tags. To add more semantics to the code, you can add the ARIA role attribute.

 <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> 
+16
source

In HTML5, a shape is the root of partitioning. It can have root or streaming content as content. figcaption is the contents of a stream and can only contain stream content as content. Thus, figcaption may not have a digit as the content.

A figure may have a different digit as content. Keep in mind that figcaption must be the first or last child .

So the code might look like this:

 <figure> <img> <figure> <figcaption></figcaption> </figure> <figcaption></figcaption> </figure> 

or

 <figure> <figcaption></figcaption> <img> <figure> <figcaption></figcaption> </figure> </figure> 

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure and https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure

+2
source

For what I see, you can use it only once within the shape: http://www.w3schools.com/tags/tag_figcaption.asp

0
source

Source: https://habr.com/ru/post/1206818/


All Articles