0Pricing
HTML Academy · Lesson

figure and figcaption Revisited

Apply figure beyond images to code, charts, and quotes.

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>

All lessons in this course

  1. aside Complementary Content
  2. figure and figcaption Revisited
  3. details and summary Disclosure Widget
  4. The progress and meter Elements
← Back to HTML Academy