What are Figure & Figcaption?
These two tags work together to add a caption to an image, chart, or code block.
Basic example:
1<figure>
2 <img src="mountain.jpg" alt="Beautiful mountain">
3 <figcaption>Figure 1: Himalayan mountain range at sunset</figcaption>
4</figure>How it works:
<figure>wraps the content<figcaption>is the caption text (usually below the image)
Chart with caption:
1<figure>
2 <img src="sales-chart.png" alt="Sales growth chart">
3 <figcaption>Figure 2: Monthly sales growth for 2025 (in thousands)</figcaption>
4</figure>Code block with caption:
1<figure>
2 <pre><code>
3 <h1>Hello World</h1>
4 <p>This is my first website</p>
5 </code></pre>
6 <figcaption>Code example 1: Basic HTML structure</figcaption>
7</figure>Multiple images, one caption:
1<figure>
2 <img src="cat1.jpg" alt="Cat 1">
3 <img src="cat2.jpg" alt="Cat 2">
4 <img src="cat3.jpg" alt="Cat 3">
5 <figcaption>Figure 3: My three cats playing together</figcaption>
6</figure>Why use them?
Groups image and caption together (they stay connected)
Screen readers read the caption with the image
Better SEO (search engines understand the relationship)
Can be styled easily with CSS
