Learn how the figure element bundles self-contained content—illustrations, diagrams, photos, or code listings—with an optional caption. Discover why it’s preferred over simple captions, how figcaption pairs content and description, and how this boosts structure and accessibility in web design.

Multiple Choice

Which tag’s content is used to describe self-contained content such as illustrations or code listings?

The main idea here is using semantic HTML to wrap content that can stand alone along with a description. The element that is built for this purpose is the figure element. It groups self-contained content—like illustrations, diagrams, photos, or code listings—and can include a caption with the figcaption element. This pairing makes it clear that the content and its description belong together as a single unit, which helps with accessibility and document structure. That’s why this is the best choice: it explicitly designates a self-contained piece of content and allows an accompanying caption. The idea that a figure only describes a caption is a common misconception; in reality, figure wraps the content and its caption, not just the caption itself. The code tag, while it can contain code, isn’t the wrapper for a self-contained item with a caption. The aside tag is for tangential or supplementary content, not the main self-contained media.

When you’re shaping a web page, you’re not just throwing content on a screen. You’re organizing ideas, media, and context so that people—and assistive tech—can understand them quickly. One small piece of that puzzle is the way we mark up self-contained content like illustrations, diagrams, photos, and code listings. That’s where the figure element enters the scene, quietly doing important work behind the scenes.

What is a figure, and why does it matter?

Think of the figure element as a sturdy box you can put content into, along with a caption that explains what that content is about. The content inside a figure is self-contained: it can stand on its own without needing extra words sprinkled around it. When you pair the content with a figcaption, you’re giving readers a clear sense of what they’re looking at and why it’s there in the first place.

This separation—content plus description—helps in several ways:

  • Accessibility: screen readers announce a figure and its caption, so users understand the relationship between the image or code and its explanation.

  • Semantics: search engines and parsers recognize that this chunk is a single, cohesive unit. That clarity can improve how the page is indexed and understood.

  • Reusability: you can reuse a figure across pages without losing its descriptive context.

A practical picture: what goes into a figure

Inside a figure, you can place a wide range of media or content. Here are common combinations you’ll see in well-structured pages:

  • an image element, such as a diagram or photograph, paired with a figcaption describing what’s in the image

  • a code block or screenshot of code, with a caption that explains what the snippet demonstrates

  • a diagram, SVG graphic, or even a video, all wrapped with a descriptive caption

The beauty here is that the figure element doesn’t prescribe what kind of media you use. It’s a flexible wrapper that communicates, “This is content that belongs together with a description.”

A quick code sketch helps make it tangible

Here’s a simple pattern you’ll recognize in clean markup:

Layered software architecture diagram
A high-level diagram of the system’s layered architecture: presentation, application logic, and data storage.

Or, if you’re showcasing code:

/* A tiny CSS snippet showing a hover effect */

button:hover { background-color: #f0f0f0; }
CSS snippet illustrating a hover state for interactive buttons.

Notice a couple of things worth calling out:

  • Alt text on images matters. It should convey the image’s purpose, not just describe its appearance. For diagrams and charts, you might summarize the key takeaway in the alt text and reserve the figcaption for deeper explanation.

  • figcaption isn’t optional if you want the full benefit. It completes the pairing by giving readers the context that ties the content to its meaning.

Beyond the basics: nuanced uses of figure and figcaption

The figure element shines when you want to group a media item with descriptive content, but there are a few clever patterns to consider.

  1. Complex media with multiple captions

Sometimes a single figure contains multiple media pieces that share a single description. In that case, you can place a concise caption in figcaption and include additional explanatory elements inside the figure as needed. The goal is to keep the main description with the media so the relationship stays obvious.

  1. Subfigures for comparisons

If you’re comparing several diagrams or screenshots, you can nest figure elements inside a parent figure to maintain a cohesive unit with a single overall caption, while each sub-media can have its own mini-caption. This keeps the page readable and maintains structure for accessibility tools.

  1. Accessibility and semantic clarity

The power of figure isn’t just about aesthetics. Screen readers announce the figure and its caption, helping users orient themselves in the content. When you combine figure with figcaption, you create a semantic pair that signals, “Here comes something you should understand with a caption that clarifies its purpose.”

Common misconceptions—clearing the air

A frequent misunderstanding is that a figure is only about captions. In reality, the figure is the container for the media and its description; the caption is a descriptive companion, not the sole content. It’s fine if the caption happens to appear visually as the main explanation, but the two elements work best when they’re connected as a unit.

Another pitfall: overusing captions or cluttering them with heavy, dense prose. You want captions that supplement and clarify, not overwhelm. A tight, purposeful caption can complement the media without stealing focus from the content itself.

Designers’ instinct: pairing media with meaning

In modern web design, we’re always balancing form with function. The figure element isn’t just a technical tag; it’s a design cue. It signals to a reader, “This content is meant to be digested together with its explanation.” That alignment makes layouts feel more cohesive and intentional.

If you’re styling with CSS, you can add subtle refinements that preserve readability and accessibility. For instance:

  • Control the space around figures so they feel like a natural part of the content flow, not an afterthought.

  • Use captions that stay legible across different screen sizes—keep typography accessible, with sufficient contrast and readable line lengths.

  • Ensure images scale gracefully with responsive designs; consider a high-contrast mode for accessibility, so captions remain legible when the page is viewed in less-than-ideal lighting.

A few practical tips for real-world usage

  • Always provide meaningful alt text for images inside figures. If the image is purely decorative and doesn’t add information, you can use an empty alt attribute (alt=""), but that should be an intentional choice rather than a default.

  • Keep figcaption concise but informative. A good caption gives enough context to stand alone if someone only glances at it.

  • Use figure for everything you want to treat as a self-contained unit—photos, diagrams, charts, code listings, and even multimedia demos. If it needs a description to make sense on its own, that’s a strong sign to wrap it in figure.

  • Don’t rely on captions alone to convey essential information. The media should convey its core message visually or through code, with the caption providing supplementary context.

Real-world scenarios: where figures shine

Education and documentation sites often rely on figures to present examples clearly. Think about a design system page that showcases a color palette, a typography scale, or a UI component example. Wrapping each example with a figure and caption ensures that readers understand not just what the media looks like, but why it exists in that exact form.

In a development blog, a code listing paired with a figcaption can explain not just what the code does, but why it matters. The caption might call out a gotcha, a best practice, or a note about browser behavior, while the code block itself shows the actual implementation.

The broader picture: semantic HTML as a storytelling tool

Semantic HTML isn’t just a tech checkbox. It’s about telling a richer, more navigable story. When content is structured with meaningful tags, readers—human or machine—can follow the thread more naturally. The figure element is a small but mighty part of that storytelling toolkit. It helps separate content from description in a way that feels intuitive, almost like a captioned photograph in a magazine, but on a webpage that’s alive with interaction and responsiveness.

If you ever wonder whether a given piece of media deserves its own space, ask a simple question: does it stand on its own and benefit from a caption that clarifies its purpose? If the answer is yes, the figure element is a natural home.

A quick look back and a forward glance

Let’s wrap with a reminder you can carry into everyday work: when you group media and meaning, you’re respecting your readers’ time and cognitive load. The figure element makes that job a little bit easier, a little more precise, and a lot more accessible. It’s not flashy, but that’s exactly the point. Good markup isn’t about flash; it’s about clarity and usability.

As you move through layouts—whether you’re designing a simple portfolio, a documentation hub, or a content-rich blog—the figure element can be a steady companion. It helps you keep related content together, making it easier for others to skim, comprehend, and engage with what you’re sharing.

If you’re curious to test the idea, try wrapping a familiar media piece—an infographic, a code snippet, or a product photo—in a figure with a caption. Notice how the rhythm of the page changes. The media gains a home, the caption gains a voice, and the entire section reads with a touch more intention.

Bottom line: the figure is a smart, purposeful container

In the grand tapestry of web design, the figure element is a quiet workhorse. It doesn’t shout; it speaks with clarity. It respects readers and accessibility tools, and it gives content a clear place to live. For self-contained pieces like illustrations, diagrams, photos, and code listings, the figure element is the natural home. Pair it with a thoughtful figcaption, and you’ve got a cohesive unit that explains itself—and invites readers to look a little closer at what’s being shared.

So next time you’re laying out a page, pause for a moment and consider: does this media deserve its own figure, with a caption that helps it tell its story? If the answer is yes, you’ve found a clean, semantic fit that makes your work a touch more thoughtful and a lot more accessible. And that, in the end, is what web design is all about: crafting interfaces that feel intuitive, inclusive, and alive.