Figures and Captions
Semantic HTML figures with images and captions for better accessibility
Figures and Captions
The figure extension creates semantic HTML5 <figure> and <figcaption> elements, perfect for images that need explanatory captions in documentation, tutorials, and educational content.
Basic Syntax
Use :::figure with an image and caption:
With Custom Labels
Add numbered or titled labels to your figures:
Common Use Cases
1. Technical Documentation
Document system architecture and diagrams:
2. Tutorial Screenshots
Explain user interface elements:
3. Before/After Comparisons
Show the result of changes:
4. Data Visualizations
Present charts and graphs:
5. Code Output Examples
Show visual results:
6. Workflow Diagrams
Illustrate processes:
Markdown in Captions
Captions support full markdown formatting:
legacy-styles.css file for details, or visit the design history page.Multiline Captions
Captions can span multiple lines for detailed explanations:
Without Captions
You can use figures without captions when the image is self-explanatory:
Label-Only Figures
Use labels without additional caption text:
Features
Semantic HTML
The extension generates proper HTML5 structure:
<figure class="markdown-figure">
<img src="image.jpg" alt="Description" loading="lazy">
<figcaption>
<strong class="figure-label">Figure 1</strong>
<span class="figure-caption-text">Caption text here.</span>
</figcaption>
</figure>
HTMLPerformance Optimization
All images include loading="lazy" for better performance:
- Reduces initial page load time
- Images load only when needed
- Improves Core Web Vitals scores
Accessibility
Figures are accessible by default:
- Semantic
<figure>element for screen readers - Alt text on images for visually impaired users
- Captions provide context for all users
- Proper heading hierarchy with labels
Integration with Other Components
In Steps
Use figures in step-by-step tutorials:
steps
Step 1: Open the Dashboard
Navigate to the main dashboard:
Step 2: Configure Settings
Access the settings panel:
In Cards
Include figures in card layouts:
Our system uses a microservices architecture:
In Asides
Add figures to callout boxes:
In Tabs
Show different views:
Best Practices
Use Descriptive Alt Text
✅ Good:

Markdown❌ Poor:

MarkdownWrite Clear Captions
✅ Good:
❌ Vague:
Number Figures Sequentially
When using multiple figures, number them in order:
Keep Labels Consistent
Choose a labeling scheme and stick to it:
✅ Consistent:
- Figure 1: Component A
- Figure 2: Component B
- Figure 3: Component C
❌ Inconsistent:
- Fig 1: Component A
- Figure 2: Component B
- Diagram 3: Component C
Reference Figures in Text
Refer to figures in surrounding text:
As shown in the diagram below, the system consists of three main layers.
The presentation layer (Figure 1) handles all user interactions.
Styling Tips
The .markdown-figure class allows for custom styling:
.markdown-figure {
margin: 2rem auto;
max-width: 800px;
text-align: center;
}
.markdown-figure img {
width: 100%;
height: auto;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.markdown-figure figcaption {
margin-top: 1rem;
font-size: 0.9rem;
color: #666;
text-align: left;
}
.figure-label {
color: #2563eb;
font-weight: 600;
}
CSSComparison with Plain Images
Plain Markdown Image

*Figure 1: System architecture showing all components*
MarkdownProblems:
- Caption is just italic text (not semantic)
- No connection between image and caption
- Screen readers don't know they're related
- Can't be styled as a unit
Figure Extension
:::figure[Figure 1: System Architecture]

Complete system architecture showing all components and their relationships.
:::
MarkdownBenefits:
- Semantic HTML structure
- Image and caption are grouped
- Screen readers announce as figure
- Easy to style consistently
- Better accessibility
Error Handling
If you forget to include an image:
An error message will display: "Error: Figure requires an image."
Real-World Examples
Documentation Example
API Reference:
Tutorial Example
Building a Layout:
Research/Technical Writing
Experimental Results:
Browser Compatibility
The <figure> and <figcaption> elements are supported in all modern browsers:
- Chrome/Edge (all versions)
- Firefox (all versions)
- Safari (all versions)
- Mobile browsers
The loading="lazy" attribute is supported in:
- Chrome 77+
- Firefox 75+
- Safari 15.4+
- Edge 79+
Older browsers simply ignore the lazy loading attribute and load images normally.
Syntax Reference
:::figure

Caption text here.
:::
MarkdownWith label:
:::figure[Figure 1: Title]

Caption with **markdown** formatting.
:::
MarkdownParameters:
label(optional) - Text for the figure label (e.g., "Figure 1", "Diagram A")- First line with image - Standard markdown image syntax
- Following lines - Caption text (supports markdown)
Related Features
- Image Compare - For before/after comparisons with slider
- Cards - For containing figures in styled boxes
- Tabs - For showing different figure variations
- Details - For collapsible figures