HTML figure Element

HTML <figure> Element: Giving Images a Voice

Images tell stories, but sometimes they need a little help — a caption, a note, or a label. The <figure> element lets you semantically group visual content with its description, using <figcaption>.

What Is the <figure> Element?

<figure> is used to group media or illustrations and their accompanying caption. The content inside should be self-contained and reusable. Common use cases include diagrams, images, code snippets, charts, and even videos.

Basic Syntax

<figure>
  <img src="apple.jpg" alt="A bright red apple">
  <figcaption>A freshly picked red apple.</figcaption>
</figure>
[Apple Image]  
A freshly picked red apple.

This structure ensures the caption is clearly associated with the visual content — semantically and visually.

Common Use Cases

  • Photos in a blog post
  • Infographics or data visualizations
  • Code block examples with explanations
  • Embedded videos or audio with context

Media Isn’t Just Images

The <figure> element can also wrap videos, audio, code samples, or any kind of illustration.

<figure>
  <pre><code>console.log('Hello, World!');</code></pre>
  <figcaption>Output of a basic JavaScript hello world script.</figcaption>
</figure>

Placement of <figcaption>

The <figcaption> can go before or after the visual content inside the <figure> — both are valid. Just keep it inside the <figure> block.

Accessibility & Best Practices

  • Always include alt text for images inside <figure>
  • Use <figcaption> to provide extra context — especially useful for screen readers
  • Keep each figure’s content logically isolated so it could stand on its own

Example: Audio Captioning

<figure>
  <audio controls src="apple-facts.mp3"></audio>
  <figcaption>Listen to 5 fun facts about apples.</figcaption>
</figure>
[Audio Player]  
Listen to 5 fun facts about apples.

Summary

The <figure> element gives structure and voice to your media. You’ve now learned to:

  • Group images, code, or audio with <figcaption>
  • Use visual content semantically for both humans and machines
  • Enhance accessibility and context across platforms

Check your understanding 1

What is the primary purpose of the <figure> element in HTML?
Choose one answer. You can try again.

Answer and explanation

To group illustrations, diagrams, or images with their captions

The <figure> element is used to encapsulate visual content such as images, diagrams, or code snippets, often paired with a caption to provide context.

Check your understanding 2

The <figcaption> element must be a direct child of the <figure> element to provide a caption.
Choose one answer. You can try again.

Answer and explanation

True

For semantic clarity and correct association, the <figcaption> should be placed as the first or last child inside the <figure> element.

Check your understanding 3

Choose the option that lists all and only the correct statements.

  1. Images like photographs or illustrations
  2. Audio and video media
  3. Code snippets or diagrams
  4. Main page navigation links
Which of the following content types can be included inside a <figure> element?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 2 and 3

<figure> can contain various media types such as images, audio, video, and code examples. It is not meant for navigational elements.

Check your understanding 4

Where should the <figcaption> be placed relative to other content inside the <figure> element?
Choose one answer. You can try again.

Answer and explanation

Either before or after the media content

The <figcaption> can appear as the first or last child of <figure> to provide an appropriate caption, improving accessibility and semantic meaning.

Check your understanding 5

Using <figure> and <figcaption> helps search engines and assistive technologies better understand the relationship between images and their descriptions.
Choose one answer. You can try again.

Answer and explanation

True

These semantic elements explicitly link visual content with descriptive captions, enhancing both SEO and accessibility.

Check your understanding 6

Choose the option that lists all and only the correct statements.

  1. It provides clear structure for assistive devices
  2. It improves visual styling automatically
  3. It maintains content and caption together during page layout changes
  4. It disables right-click on images
Why is grouping visual content with captions inside <figure> beneficial?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 3

Grouping with <figure> helps screen readers relate images and captions and ensures both move together when the layout changes. Styling and right-click behavior are not controlled by this element.

What’s Next?

Up next: the <time> element — where we give dates and times both meaning and machine readability.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: HTML figcaption Element →