Description
The HTML element <figcaption> is used to define a caption or label for the <figure> element.
The element <figcaption> must be defined as either the first child or the last child of the <figure> element.
The below table summarizes its usage.
| Usage Details | |
| Placement | It is displayed as a Block element. |
| Contents | It can contain Block elements, Inline elements, and text. |
| Tags | Both opening and closing tags are required. |
| Versions | HTML5 |
Syntax
Here is the basic syntax of the <figcaption> element.
<figcaption>...</figcaption>
Examples
In the below example, the <figcaption> element is used to add a caption to the <figure> element.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Element - figcaption</title>
</head>
<body>
<figure>
<img src="/assets/logo/logo.png" alt="logo">
<figcaption>Random Codez - Logo</figcaption>
</figure>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <figcaption> tag.
| Attribute Type | Details |
| Element-Specific Attributes | The tag <figcaption> doesn't have any element-specific attributes. |
| Global Attributes | Like all other HTML tags, the tag <figcaption> supports the HTML Global Attributes. |
| Event Attributes | The tag <figcaption> also supports the HTML Event Attributes. |
Browser Compatibility
The tag <figcaption> is supported in all modern browsers.
- Google Chrome 6+
- Internet Explorer or Edge 9+
- Firefox 4+
- Apple Safari 5.1+
- Opera 11.1+