HTML <figure> Tag

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <figure> element represents self-contained content — often an image, diagram, code sample, or quote — referenced as a single unit. An optional <figcaption> provides its caption (first or last child).

A figure is usually mentioned in the main text but can be moved (sidebar, appendix, another section) without breaking the document’s meaning. Prefer <img> with a real alt for pictures inside the figure.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015.

One unit.

The figure, its caption, and its contents are treated together. Caption with at most one <figcaption>.

HTML Syntax

syntax.html
<figure> content [<figcaption>…</figcaption>]</figure>

Both start and end tags are required. Content is flow content, optionally with one <figcaption> as the first or last child.

Attributes

<figure> has no element-specific attributes. Use globals when needed:

AttributeDescriptionTry it
classStyle hook for the figure frame or layoutTry it
idUnique target for in-page links (for example href="#fig-1")Try it
langLanguage of the figure when it differs from surrounding textTry it

Global Attributes

The <figure> tag also supports the Global Attributes in HTML.

Live Preview

Switch between a bare figure and a figure with <figcaption>.

A real <figure>. Caption is optional but recommended when readers need a label.

Figure
JavaScript logo
JavaScript logo

Image with figcaption as the last child.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Image with Caption

Most common pattern: media inside <figure>, caption last.

HTML
<figure>
  <img src="/images/javascript.png" alt="JavaScript logo" width="128" height="128">
  <figcaption>JavaScript logo</figcaption>
</figure>
Try It Yourself

How It Works

  1. Open <figure> for the self-contained unit.
  2. Add the image with a meaningful alt.
  3. Add <figcaption> as the last (or first) child.
  4. Close the figure so caption and media stay one unit.

Example 2 — Figure Without Caption

A figure is valid without <figcaption> when no caption is needed.

HTML
<figure>
  <img src="/images/circle_image.jpg" alt="Orange circle on a light background" width="160" height="160">
</figure>
Try It Yourself

How It Works

  1. Wrap the content in <figure> when it is self-contained.
  2. Skip figcaption if there is nothing useful to caption.
  3. Keep a good alt on meaningful images.
  4. Add a caption later if you start referring to “Figure 1” in the text.

Example 3 — Code Sample Figure

Figures work well for snippets you reference from the article.

HTML
<figure>
  <figcaption>Example: log a greeting.</figcaption>
  <pre><code>console.log("Hello");</code></pre>
</figure>
Try It Yourself

How It Works

  1. Put the caption first (valid) or last.
  2. Wrap the sample in <pre><code> for formatting.
  3. Keep the figure movable — the article can say “see the example above/below.”
  4. One figcaption only for that figure.

Example 4 — Quote as a Figure

A block quote with attribution in the caption stays one self-contained unit.

HTML
<figure>
  <blockquote>
    If debugging is the process of removing software bugs,
    then programming must be the process of putting them in.
  </blockquote>
  <figcaption>Edsger Dijkstra</figcaption>
</figure>
Try It Yourself

How It Works

  1. Place the quote in <blockquote> inside the figure.
  2. Credit the source in <figcaption> (optionally with <cite>).
  3. Keep quote + credit together as one figure unit.
  4. Reference it from the prose without depending on exact page position.

Edge Cases & Pitfalls

Most figure mistakes are treating it like a generic box or misplacing the caption.

semantics

Not a styled div

Use <figure> for self-contained content you reference as a unit. Use a plain <div> for layout-only wrappers.

caption

Caption position

<figcaption> must be the first or last child. Do not place it between other figure children.

images

Keep real alt

A caption does not replace alt on meaningful images. Write both when both jobs are needed.

aria

Role is figure

Implicit ARIA role is figure. With a figcaption descendant, other roles are not permitted on the figure.

count

One caption max

Use at most one <figcaption> per figure. The first one found is treated as the caption.

Browser Support

The <figure> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<figure>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera all support figure with optional figcaption.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer 9+
Supported
<figure> Widely supported

Bottom line: Safe to use everywhere for self-contained media and samples. Pair with figcaption when readers need a label.

Key Takeaways

  • Role: <figure> wraps self-contained content as one unit.
  • Caption: optional <figcaption> as first or last child.
  • Contents: images, diagrams, code, quotes, poems, and more.
  • Not for layout: avoid using figure as a generic card wrapper with no self-contained meaning.

One line: use <figure> for content that stands alone as one referenced unit.

Default CSS Settings

Typical user-agent styling (exact margins can vary by browser):

default.css
figure {
  display: block;
  margin-block: 1em;
  margin-inline: 40px;
}

Many designs reset the side margin and style figure + figcaption together for a card-like frame.

Frequently Asked Questions

The figure element represents self-contained content—often an image, diagram, code sample, or quote—that can be referenced as one unit, optionally with a figcaption.
No. A figure can stand alone. When you add a caption, use one figcaption as the first or last child of the figure.
div is a generic container with no meaning. figure marks self-contained content that belongs together and can usually be moved without breaking the main article flow.
No. It only supports global attributes such as class, id, and lang.
Place figcaption as the first or last child of figure. That caption can provide the figure’s accessible name.
Yes. Common uses include illustrations, diagrams, code snippets, poems, and block quotes—anything that forms one self-contained unit.

Next: font

See why the obsolete font element should not be used in new pages.

font tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful