The HTML <figcaption> tag
The HTML <figcaption> element provides a caption for its parent <figure>. It must be the figure's first or last child, and it provides the figure's accessible name.
Overview
The <figcaption> element provides a caption or label for a <figure>. Place it as the first or last child of the figure — for a caption above or below the content respectively — and nowhere else.
A caption can do several jobs: number a figure ("Figure 3"), credit a source, or explain what the reader is looking at. Crucially, it provides the figure's accessible name, so assistive technology announces the caption and content together.
That is also why it differs from an image's alt text. The alt attribute describes the image for people who cannot see it; <figcaption> is a visible caption shown to everyone. The two complement each other — a figure with an image usually wants both.
Syntax
<figure>
<img src="photo.jpg" alt="">
<figcaption>A sunset over the sea.</figcaption>
</figure>
Example
<figure style="margin:0;">
<img src="https://codeshack.io/web/img/icon.png" alt="" width="56" height="56">
<figcaption style="font-size:.9rem;color:#64748b;">The CodeShack mark.</figcaption>
</figure>
Best practices
Frequently asked questions
Where does figcaption go?
What is the difference between figcaption and alt?
<figcaption> is a visible caption that labels the whole figure; alt is a text alternative that describes an image for people who cannot see it.Can a figure have more than one figcaption?
<figcaption>.