A figure is a self-contained piece of content that is referred to from the main text, such as an image, a chart or a code example. A figcaption gives it a caption.
<figure>
<img src="https://placehold.co/320x160/f8f2ee/49454f?text=Reading+corner" alt="Armchairs and a lamp in a quiet corner of the shop">
<figcaption>The reading corner on the first floor.</figcaption>
</figure>
alt versus figcaption
altdescribes the image for someone who cannot see it.figcaptionis a visible caption that adds context for everyone.
They do different jobs. Do not copy the caption into the alt.
figure for more than pictures
<figure>
<pre><code><p>Hello</p></code></pre>
<figcaption>The simplest paragraph.</figcaption>
</figure>
Where the caption goes
figcaption can be the first or the last child of the figure. Most pages put it last.
Not every image needs a figure
figure when the image is content that has a caption or is referred to. A decorative image or a logo does not need one.