Back to subject
HTML5/HTML Figure and Figcaption

Keep a Picture and Its Caption Together

Practical lesson

Let's group an image with the caption that explains what the image represents.

- <figure> creates a self-contained piece of content such as an image, diagram, code sample, or illustration. - Put the main content inside <figure>. - Use <figcaption> for a visible caption that describes or identifies that content. - Keep the caption connected to the thing it describes rather than placing unrelated text outside the figure. - The image still needs a useful alt attribute when it conveys information. - A caption and alt text do different jobs: the caption is visible context, while alt text is the text alternative for the image itself. - A figure can contain more than one related item when they belong together.

The practical idea is that <figure> groups the content and <figcaption> gives that group a visible explanation.

Try it yourself
Code

Starter example

Code
<figure>
  <img src="chart.png" alt="A bar chart showing sales growth">
  <figcaption>Sales increased during 2026.</figcaption>
</figure>
Live preview