Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 6 of 7
Figure, Figcaption & Image Accessibility
The <figure> and <figcaption> elements provide semantic structure for images, diagrams, charts, code snippets, and other self-contained content with captions. Proper image accessibility through alt text, decorative image handling, and ARIA roles ensures your content is usable by everyone, including visually impaired users. Google also uses alt text for image search ranking.
Figure, Figcaption & Alt Text Rules
<figure> groups an image (or other content) with its caption. <figcaption> provides the caption text. Together they create a semantic unit that screen readers announce as related content.
<figure>
<img src='chart.png' alt='Revenue grew 25% in Q3'>
<figcaption>Figure 1: Q3 Revenue Growth</figcaption>
</figure>
Alt text rules:
1. Informational images - Describe what the image shows:
alt='Bar chart showing 25% revenue increase in Q3 2025'
2. Decorative images - Use empty alt (screen readers skip it):
<img src='decoration.svg' alt='' role='presentation'>
3. Images of text - Write the text in alt:
alt='SALE: 50% off all courses this weekend'
4. Complex images (charts/diagrams) - Short alt + long description:
alt='Q3 revenue chart' aria-describedby='chart-desc'
<p id='chart-desc'>Revenue increased from $2M to $2.5M...</p>
Never write alt='image of...' - screen readers already say 'image' before reading alt text.
Use figure and figcaption to bind descriptive captions to illustrations and diagrams
Figure & Accessibility Example
<!DOCTYPE html>
<html>
<head>
<style>
figure { margin:0; max-width:400px; border-radius:12px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,0.1); }
figure img { width:100%; display:block; }
figcaption { padding:12px 16px; background:#f8f8f8; color:#555; font-style:italic; }
</style>
</head>
<body>
<h1>Figure & Figcaption</h1>
<!-- Figure with caption -->
<figure>
<img src="https://picsum.photos/400/250" alt="Scenic mountain landscape with snow-capped peaks">
<figcaption>Figure 1: Mountain landscape at sunset</figcaption>
</figure>
<!-- Decorative image (screen readers skip) -->
<img src="https://picsum.photos/400/5" alt="" role="presentation" style="width:100%;margin:20px 0">
<p>The decorative divider above has an empty alt attribute - screen readers ignore it entirely.</p>
</body>
</html>Quick Quiz: Image Accessibility
Finished this lesson?