figure

The HTML <figure> element groups self-contained content such as an image, diagram, chart, or code sample. An optional <figcaption> can explain what the figure represents.

What you will learn

Basic example

<figure>
  <img src="architecture.png" alt="Three layers of the application">
  <figcaption>Figure 1: The application layers.</figcaption>
</figure>

A figure is related to the surrounding content, but it can be moved to another place, such as an appendix, without losing its identity. The caption belongs to the figure rather than being a separate heading.

More than images

Use figure for a chart, code sample, quotation, or other self-contained content when it has a clear relationship with the surrounding explanation.

<figure>
  <pre>const total = price * quantity;</pre>
  <figcaption>Example: calculate the total price.</figcaption>
</figure>

figure is not a generic layout box

If a group exists only to apply CSS or arrange elements, use a neutral container such as div or a more meaningful structural element. Semantic elements should describe the content, not just its visual position.

Accessibility notes

Common mistakes

Related pages