The <figure> tag in HTML is used to include self-contained content like images, diagrams, or code that is related to the main content but can stand independently.
- Used for illustrations, images, diagrams, or code snippets.
- Content is related to the main flow but can be moved or removed without affecting it.
- Introduced in HTML5 for better semantic structure.
Syntax:
<figure> Image content... </figure>
Attributes
- <img src="">: The img src attribute is used to specify the image source and add an image to the document.
- <figcaption>: The figcaption tag is used to provide a caption or description for the content inside the <figure> element.
Example: Implementation of figure tag.