'what is the usage of HTML5 figure with img
Is there any specific advantage/usage of using HTML5 <figure> over <img>?
I think <figure> is useless without <figurecaption>, isn't it?
It will be helpful if explain with an example.
Solution 1:[1]
The tag provides a container for content that is equivalent to a figure or diagram in a book. It can be used to group a caption with one or more images, a block of code or other content.
In other words, enables us to work more freely, realistically with images, diagrams by enabling to group them & caption one or images with a single caption.
Solution 2:[2]
HTML5 figure is used whenever you use img, video tag with caption (figcaption) on it
If you have a number of related images (or other content) with caption text, you can use nested figure elements to associate both a group caption and an individual caption to each instance using the figcaption element.
<figure role="group">
<img src="castle-etching.jpg" alt="The castle has one tower, and a tall wall around it.">
<figcaption>Charcoal on wood. Anonymous, circa 1423.</figcaption>
</figure>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Viral Jain |
| Solution 2 | Dipak |
