HTML <figure> Element
The <figure> tag in HTML is used to group together a <img> tag or similar content with its caption or legend using the <figcaption> tag. This helps to create a semantic relationship between the image and its caption.
Here is an example of how to use the <figure> tag:
<figure>
<img src="../../images/Logo_BluecodeAcademy_horizontal.png" alt="Example image">
<figcaption>This is an example image</figcaption>
</figure>
Table of <figure> tag attributes:
| Attribute | Description |
|---|---|
| class | Specifies one or more class names for the <figure> element |
| id | Specifies a unique id for the <figure> element |
| style | Specifies an inline CSS style for the <figure> element |
Remember to always include a <figcaption> tag inside the <figure> element to provide a caption or legend for the content. This helps screen readers and search engines better understand the relationship between the image and its description.