HTML・Images and media

Add a description to an image

A tag that bundles an image and the "caption (description)" below it into one group. With figure and figcaption, add a few words to a photo.

Earlier we displayed an image with <img>. This time, one step further. We’ll learn how to properly pair a photo or diagram with a description (a caption) of “what this image is.” Below the photos in a picture book or the news, there’s a little description in small text, right? That’s the one.

How to write figure

Wrap <img> in <figure>, and inside it add the description with <figcaption>.

<figure>
  <img src="/shima.jpg" alt="A long-tailed tit on the snow">
  <figcaption>The long-tailed tit, called the snow fairy</figcaption>
</figure>
The description text shows right below the image, attached as a caption.

Let’s break that down.

TagMeaning
<figure>The “container” that bundles a figure (image) and its description
<img>The usual image tag
<figcaption>figure caption, the image’s description

In many browsers, the text of <figcaption> is shown right below the image, as a caption. The point is that it conveys “the image” and “its description” are one group.

How are alt and figcaption different?

You might be thinking, “Wait, wasn’t alt a description too?” Their roles are different.

Way of describingWhat kind of description
altThe stand-in text for when the image can’t be shown. For screen readers
<figcaption>A caption added to the image that everyone can see

alt is a description for “people who can’t see it, or times it can’t be shown,” and <figcaption> is a description for “everyone who can see it.” They’re both fine to have—descriptions with different roles.

There’s one more upside to wrapping in <figure>. Just placing an image and its description side by side and declaring them one group with <figure> come across differently to screen readers. When they’re merely side by side, they’re read separately as “an image” and “a different piece of text,” but inside <figure> it comes across as “this description corresponds to this image.” Even though the look is the same, the connection in meaning grows stronger.

You can bundle several images together too

The image you can put inside <figure> isn’t limited to one. If there are two photos you want people to compare, bundle both into a single <figure>, and adding just one <figcaption> is enough.

<figure>
  <img src="/shima-summer.jpg" alt="A long-tailed tit in summer plumage">
  <img src="/shima-winter.jpg" alt="A long-tailed tit in winter plumage">
  <figcaption>A long-tailed tit in summer plumage (left) and winter plumage (right)</figcaption>
</figure>
Even with two images lined up, there’s only one caption for the whole thing.

Rather than “making a figure for each image one by one,” it’s “bundle the related images together, and give one description for all of them.” This, too, is a way of writing that only works because figure and figcaption come as a set.

Summary of this lesson

  1. Bundle an image and its description as a set with <figure>
  2. Write the description (caption) with <figcaption>
  3. alt (for when it can’t be seen) and <figcaption> (visible to everyone) have different roles

Try it: add a description to a photo

Let’s wrap the photo of Shima you placed earlier in <figure> and add a <figcaption>.

<figure>
  <img src="shima.png" alt="A photo of Shima">
  <figcaption>Nice to meet you, I'm Shima</figcaption>
</figure>
<h1>Shima</h1>

We just wrapped the <img> you placed in the previous lesson with <figure></figure> and added one line of <figcaption>. The <h1> below stays as is.

Browser display. Below Shima’s round photo is the description “Nice to meet you, I’m Shima,” and below that is the heading “Shima”
A small description was added right below the photo.

alt is for when it can’t be seen, and <figcaption> is a description everyone can see—writing both is thoughtful. Just adding a few words to an image makes for a much kinder page.

FAQ

Can I skip figcaption and use figure on its own?
It's possible as far as the syntax goes, but then there's no point in using `<figure>`. If you're not pairing it with a description, plain `<img>` on its own is enough, just like before.
Can I put two images in one figure?
Yes. Bundle the photos you want to show side by side into one `<figure>`, add just a single `<figcaption>`, and it becomes a description covering both images together.
Can I write figcaption above the img?
Yes. Whether you place it above or below isn't a difference in meaning—it's a matter of visual preference. Most sites place it below the image, but it displays fine above too.