HTML <figcaption>
tag
The <figcaption>
tag is used to provide a caption or title for a <figure>
element. This can be useful when you have an image or multimedia content that needs additional context or description.
Example:
<figure>
<img src="example.jpg" alt="Example image">
<figcaption>This is an example image</figcaption>
</figure>
In the above example, the <figure>
element contains an image and a caption provided by the <figcaption>
tag.
Attributes of the <figcaption>
tag:
Attribute | Description |
---|---|
align | Specifies the alignment of the caption. Possible values are left , right , center , or justify . |
class | Specifies one or more class names for the caption (referenced by the CSS). |
style | Specifies an inline CSS style for the caption. |
Example with attributes:
<figure>
<img src="example.jpg" alt="Example image">
<figcaption align="center" class="caption" style="color: red;">Centered caption with red text</figcaption>
</figure>
In the above example, the <figcaption>
tag has the attributes align="center"
, class="caption"
, and style="color: red;"
which aligns the caption to the center, applies the class name for styling, and sets the text color to red.