Live Preview
A figure grouping an image placeholder and caption:

By the end of this tutorial, you’ll group images, videos, and diagrams in semantic, accessible figure elements.
The HTML <figure> tag encapsulates self-contained media content, such as images and videos, optionally with a <figcaption> caption. This guide covers syntax, attributes, accessibility, and best practices for beginners and web developers alike.
Wrap media in <figure> with optional figcaption.
Pair photos with descriptive captions.
Embed videos as labeled media units.
Mark self-contained content for SEO and a11y.
Style borders, spacing, and caption layout.
Know when semantic grouping beats a generic box.
<figure> Tag?The figure element (<figure>) is a semantic HTML5 container for self-contained content—typically an image, illustration, diagram, video, or code snippet—that is referenced from the main document flow. It can include an optional <figcaption> element for a visible caption or legend.
A figure does not require a caption. Add figcaption when a visible label helps readers understand the media.
Figures are ideal for content that could be moved to an appendix without breaking the narrative. They improve structure, accessibility, and how search engines interpret your page.
Wrap your media inside opening and closing <figure> tags. Add <figcaption> when you need a caption:
<figure>
<img src="your-image.jpg" alt="Description of the image">
<figcaption>Your Caption Here</figcaption>
</figure>figure.figcaption is optional but should be used when a caption adds value.figcaption must be a direct child of figure.alt text on images inside a figure.| Pattern | Code Snippet | Notes |
|---|---|---|
| Image figure | <figure><img><figcaption> | Most common pattern |
| Video figure | <figure><video><figcaption> | Self-contained media block |
| No caption | <figure><img></figure> | Valid without figcaption |
| Styled figure | class="media-figure" | CSS hook on figure |
| Caption element | <figcaption> | Optional child of figure |
| Default style | Block container | Minimal browser defaults |
<figure> vs <div>Both can wrap media visually, but only figure carries semantic meaning:
| Feature | <figure> | <div> |
|---|---|---|
| Semantic role | Self-contained media/content | Generic container |
| Caption support | <figcaption> | Use paragraph or span manually |
| SEO & a11y | Built-in figure semantics | Requires extra markup or ARIA |
| Best for | Images, charts, videos, code blocks | Layout and non-semantic grouping |
<figure> and <figcaption>These elements work together as a labeled media unit:
| Element | Role | When to use |
|---|---|---|
<figure> | Group container | Wrap images, videos, diagrams, code snippets |
<figcaption> | Caption or legend | Describe what the figure shows (optional) |
| Together | Labeled figure | Articles, tutorials, galleries, documentation |
| figure alone | Valid pattern | Caption not always required |
The <figure> tag has no tag-specific attributes. Use global attributes on the figure, and put media-specific attributes on child elements like img or video:
class GlobalCSS hook for borders, spacing, and layout of the figure block.
class="media-figure"id GlobalUnique identifier for linking or scripting the figure.
id="chart-1"lang GlobalLanguage of caption or content when it differs from the page.
lang="fr"style GlobalInline styling for one-off figure presentation (prefer CSS classes).
style="border: 1px solid #ccc;"<figure class="media-figure">
<img src="your-image.jpg" alt="Description of the image" class="custom-image">
<figcaption class="custom-caption">Your Caption Here</figcaption>
</figure>Attributes like src and alt belong on img, not on figure itself.
Styled figures, image captions, and embedded video patterns with copy-ready code and live previews.
A figure grouping an image placeholder and caption:
The most common use case for <figure> is combining an image with a descriptive figcaption.
<figure>
<img src="example.jpg" alt="An example image">
<figcaption>This is an example image</figcaption>
</figure>Use <figure> for blog post photos, product gallery images, chart and diagram blocks, tutorial screenshots, embedded videos, code listing excerpts, and pull-quote illustrations that stand apart from the main text.
Wrap videos in figure to provide a self-contained media block with an optional caption:
<figure>
<video controls>
<source src="your-video.mp4" type="video/mp4">
</video>
<figcaption>Your Video Caption</figcaption>
</figure>Apply class attributes to the figure, image, and figcaption for consistent design system styling.
<figure class="media-figure">
<img src="your-image.jpg" alt="Description of the image" class="custom-image">
<figcaption class="custom-caption">Your Caption Here</figcaption>
</figure>Figures have minimal browser defaults. Style the container and caption for polished media blocks:
max-width Constrain image widthborder Card-style figuresfigcaption Caption typographymargin Spacing from text/* Figure container styling */
figure.media-figure {
max-width: 420px;
margin: 1.5rem 0;
padding: 0.75rem;
border: 1px solid #cbd5e1;
border-radius: 10px;
background: #fff;
}
figure img {
display: block;
width: 100%;
border-radius: 8px;
}
figure figcaption {
margin-top: 0.5rem;
font-size: 0.875rem;
color: #64748b;
text-align: center;
}Live styled figure
Semantic figures help all users understand media in context:
figcaption does not replace the alt attribute.Place an image, video, or diagram inside figure.
Include figcaption when a visible label helps readers.
Assistive tech and search engines recognize a labeled media unit.
Readers and search engines understand images and videos in context.
The <figure> element is fully supported in all modern browsers and Internet Explorer 9+.
From legacy Internet Explorer to the latest mobile browsers — figure is a safe HTML5 building block for labeled media.
Bottom line: Ship semantic media groups with confidence. The <figure> element is safe to use in every production environment today.
Harnessing the power of the <figure> tag allows you to create well-structured and accessible media content on your web pages. Incorporate this element into your HTML markup to provide a richer and more meaningful experience for your audience.
Pair figure with optional figcaption, keep alt text on images, and use CSS classes for consistent styling across articles, galleries, and documentation.
alt text on images inside figurefigcaption for descriptive, relevant captionsalt with figcaption alone<figure>Bookmark these before you ship — they’ll keep your media blocks semantic and accessible.
<figure> wraps self-contained content.
figcaption adds visible context when needed.
Semantic grouping beats generic containers.
ComparisonWorks with photos, diagrams, and embedded media.
Use CaseStyle borders, spacing, and captions freely.
StylingHTML5 semantic element with full browser support.
Compatibilityfigcaption caption.figcaption is optional but recommended when a visible caption adds context for readers.figure is semantic and marks self-contained media. div is a generic container with no built-in meaning.figure and media attributes on child elements like img.Group images and videos with figure and figcaption in the interactive HTML editor.
6 people found this page helpful