HTML Reference ยท Text Content
The <figure> element
Reference for the HTML <figure> element: self-contained images, diagrams, code and quotes, captions with <figcaption>, examples and technical details.
The <figure> element wraps self-contained content that the main text refers to but that could be moved elsewhere, such as to an appendix or the side of the page, without breaking the flow. Images, charts, diagrams, code listings, poems and quotations are typical figures. An optional <figcaption> gives it a caption.
<figure> <img src="/samples/sunset.svg" alt="Orange sun setting behind two hills"> <figcaption>Sunset over the valley.</figcaption> </figure>
Try it
The caption can come first or last; both are valid.
Attributes
This element has no attributes of its own. It accepts the global attributes.
Usage notes
- The self-contained test. Ask: "Could this move to another spot on the page and still make sense?" If yes,
<figure>fits. A decorative image in the middle of a sentence is not a figure. - One caption at most. A figure can have zero or one
<figcaption>, and it must be the first or last child. - Caption vs alt text. The caption is visible to everyone and adds context; an image's
altdescribes what the image shows. A figure with a caption still needs goodalttext. - Several items, one caption. A figure may contain several images or blocks that share one caption, such as a before/after pair.
- Default margins. Browsers give figures a margin of about 1em top and bottom and 40px on each side; reset it with CSS if needed.
- Accessibility. With a
<figcaption>, the caption becomes the figure's accessible name, so assistive technology can announce what the figure is about.
Technical summary
| Content categories | Flow content, palpable content |
| Permitted content | A <figcaption> followed by flow content; or flow content followed by a <figcaption>; or flow content |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts flow content |
| Implicit ARIA role | figure |
| DOM interface | HTMLElement |
| Default display | block |
Browser support
Supported in every browser.
Related
<figcaption>โ the figure's caption<img>and<picture>โ images inside figures<blockquote>โ quotations, often placed in a figure<pre>โ code listings- Lesson: Figures and Captions
- Lesson: Images