figure and figcaption Revisited
Apply figure beyond images to code, charts, and quotes.
figure and figcaption Revisited is a free HTML Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the HTML Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
figure Beyond Images
The <figure> element is not just for images — it marks any self-contained content that is referenced from the main text:
- Code examples
- Mathematical equations
- Charts and diagrams
- Quotations
- Audio and video with captions
Code Listing in figure
Label code examples as figures:
<figure id="code-1">
<figcaption>Listing 1: A simple JavaScript greeting function.</figcaption>
<pre><code>function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet('World'));</code></pre>
</figure>
<p>As shown in <a href="#code-1">Listing 1</a>, the function...</p>Audio in figure
Audio with a descriptive caption:
<figure>
<audio controls src="podcast-episode-42.mp3">
Your browser does not support audio.
</audio>
<figcaption>Episode 42: HTML5 Deep Dive — 48 minutes.</figcaption>
</figure>Video in figure
Video with a caption describing its content:
<figure>
<video controls width="800" height="450">
<source src="tutorial.mp4" type="video/mp4">
<source src="tutorial.webm" type="video/webm">
</video>
<figcaption>Tutorial: Building a responsive navigation menu in 10 minutes.</figcaption>
</figure>Chart in figure
A chart image with data source as caption:
<figure>
<img
src="revenue-chart.png"
alt="Line chart showing revenue growth from $2M in 2020 to $8M in 2024"
width="800"
height="400"
>
<figcaption>
Figure 3: Annual revenue growth 2020-2024.
Source: Finance Department Annual Report.
</figcaption>
</figure>SVG Diagram in figure
An SVG diagram with a caption:
<figure>
<svg role="img" aria-labelledby="diagram-title" width="400" height="300">
<title id="diagram-title">Three-tier architecture diagram</title>
<!-- SVG content -->
</svg>
<figcaption>Figure 4: Client-server-database three-tier architecture.</figcaption>
</figure>Quotation in figure
Extended quotation as a figure:
<figure>
<blockquote cite="https://www.w3.org/TR/html52/">
<p>The main element represents the main content of the body of a document
or application.</p>
</blockquote>
<figcaption>— W3C HTML5.2 Specification</figcaption>
</figure>alt vs figcaption Revisited
Clarifying the distinction once more:
- alt — invisible; replaces the image for screen readers; describes what the image shows
- figcaption — visible; provides context, attribution, or numbering; describes what the figure means
<figure>
<img src="volcano.jpg" alt="Ash plume rising 2km above Mount St. Helens">
<figcaption>Figure 7: The 1980 eruption. Source: USGS.</figcaption>
</figure>figcaption Placement
figcaption can be the first or last child of figure:
<!-- Caption above the content (common for code listings) -->
<figure>
<figcaption>Listing 1: Hello World</figcaption>
<pre>...</pre>
</figure>
<!-- Caption below the content (common for images) -->
<figure>
<img src="photo.jpg" alt="...">
<figcaption>Caption below the image</figcaption>
</figure>Figure Numbering with CSS Counters
Auto-number figures with CSS counters:
/* In CSS: */
main {
counter-reset: figure-counter;
}
figure {
counter-increment: figure-counter;
}
figcaption::before {
content: 'Figure ' counter(figure-counter) ': ';
font-weight: bold;
}When Not to Use figure
Do not wrap every image in figure:
- Decorative images (empty alt) → just use
<img alt=""> - Images that are purely presentational → CSS background-image
- Avatar photos in a list of users → just use
<img> - Logo in the header → just use
<img>
Quick Check
Which child of figure provides a visible caption shown to all users?
Recap: figure Revisited
figure essentials revisited:
<figure>— self-contained referenced content (images, code, charts, audio, quotes)<figcaption>— visible caption, first or last child- alt text = invisible description; figcaption = visible context
- Auto-number with CSS counters
- Not every image needs a figure
Frequently asked questions
Is the “figure and figcaption Revisited” lesson free?
Yes — the full text of “figure and figcaption Revisited” is free to read here on the web, and the HTML Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the HTML Academy course, upgrade to CoddyKit PRO.
What will I learn in “figure and figcaption Revisited”?
Apply figure beyond images to code, charts, and quotes. You practise HTML Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start HTML Academy?
No prior experience is required. HTML Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “figure and figcaption Revisited” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this HTML Academy lesson?
Yes. Every HTML Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- aside Complementary Content
- figure and figcaption Revisited
- details and summary Disclosure Widget
- The progress and meter Elements