# `<figure>`

> The `<figure>` HTML element represents self-contained content, such as images, diagrams, code snippets or videos, with an optional `<figcaption>` element.

## When should I use figure and figcaption in HTML?

The element that represents self-contained content, such as an image with an optional caption, code snippet or diagram. It's used to group media and its associated text, allowing for more flexible placement and styling.

- Topic: Images & Icons
- Type: tag
- Browser support: Chrome 8+, Chrome Android 18+, Edge 12+, Firefox 4+, Firefox Android 4+, Safari 5.1+, Safari iOS 5+

## Example

Wrong:

```html
<div class="figure">
  <img src="chart.png" alt="Sales by month">
  <p class="caption">Sales grew in spring.</p>
</div>
```

Right:

```html
<figure>
  <img src="chart.png" alt="Sales by month">
  <figcaption>Sales grew in spring.</figcaption>
</figure>
```

`<figcaption>` names the `<figure>` for assistive tech, which a styled `<p>` cannot do.

## Common mistakes

- Wrapping every image in `<figure>`, including decorative ones.
- Skipping `alt` because the caption already describes the image.

## Key points

- `<figure>` wraps self-contained content that could move elsewhere without breaking the text.
- A `<figcaption>` is the first or last child of `<figure>`.
- An image in a figure still has its own `alt`, even with a caption.

## Interview questions

### Can figure hold code or a quote instead of an image?

Yes, `<figure>` can hold any flow content, such as code listings, quotes, tables or videos.

### Should alt repeat the figcaption text?

No, `alt` describes the image and the caption adds context. Avoid making both say the same thing.

## Related cards

- [`<figcaption>`](https://wonderium.dev/html/figcaption.md)
- [`<img>`](https://wonderium.dev/html/img.md)
- [figure](https://wonderium.dev/a11y/figure.md)
- [`<blockquote>`](https://wonderium.dev/html/blockquote.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/figure
- Last updated: 2026-11-25
