Course contentsShow
← Web Development
Lesson 1006 of 2,98218. Accessibility FundamentalsFree lesson

Figure and Figcaption for Images

Learn how to semantically associate images with their captions for better context.

Figure and Figcaption for Images

What you'll learn: How to semantically link images with their captions so screen readers and browsers understand the relationship between them.

The Problem with Generic Markup

When you place an image and its caption side-by-side using just <img> and <p> tags, they're visually close but semantically disconnected. Assistive technologies don't know they're related—it's like putting two strangers next to each other without introducing them.

The Semantic Solution

The <figure> element creates a container that says "these things belong together," while <figcaption> provides the descriptive text. This pairing tells browsers and assistive technologies that the caption explicitly describes the figure content.

<figure>
  <img src="sunset.jpg" alt="Golden sun setting over ocean waves">
  <figcaption>Sunset at Pacific Beach, taken July 2024</figcaption>
</figure>

Why This Matters for Accessibility

When a screen reader encounters this structure, it announces the relationship: "Figure" → reads the alt text → "Caption: Sunset at Pacific Beach..." This context helps users understand not just what the image shows (from alt), but also why it's included and any additional context.

Beyond Just Images

While commonly used for images, <figure> can wrap diagrams, code snippets, quotes, or any self-contained content that needs a caption. The <figcaption> can appear before or after the content—wherever makes sense visually.

The Alt vs Figcaption Distinction

Think of alt as describing what you see in the image itself, while figcaption provides context about the image—like when it was taken, who created it, or why it's relevant to the surrounding content.

Key Takeaway: Use <figure> and <figcaption> to semantically associate images with their captions, making the relationship clear to all users and assistive technologies.