How to caption images with figure

Group self-contained content

A figure can contain an image, diagram, code sample, or other item referenced by the surrounding text.

<figure>
  <img src="/images/growth-chart.svg"
       alt="Sales rise steadily from January to June">
  <figcaption>Monthly sales, January–June 2026.</figcaption>
</figure>

Caption versus alt text

The caption is visible context for everyone. Alt text replaces the meaningful information in the image. Avoid repeating exactly the same sentence in both.

Place the caption

A figure may have one figcaption, placed first or last inside it. Keep both the media and caption within the figure.

Do not overuse figure

A logo, icon, or image that is simply part of a link usually does not need a figure. Use it when the content is self-contained and the caption helps identify or explain it.