CKTIS / HTML
figure — a self-contained unit with an optional caption
The `figure` element groups a self-contained unit such as an illustration or code listing. It can include an optional `figcaption` caption.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<figure>…<figcaption>…</figcaption></figure>figure represents a self-contained unit, typically referenced as a whole. It suits photos, diagrams, and code listings; it is not exclusively an image container. Self-contained does not mean independent of context.
Use it wherever flow content is allowed. It contains flow content and at most one direct figcaption element, placed as its first or last child. The caption is optional. Both figure tags are required; the element supports global attributes.
Refer to the unit by a label such as Listing 1, rather than a position such as “above”. This makes moving content easier without changing meaning. The example displays code as text without executing it.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Figure example</title>
<p>Listing 1 shows a multiplication expression.</p>
<figure>
<pre><code>6 * 7</code></pre>
<figcaption>Listing 1: Multiplication expression</figcaption>
</figure>
</html>Result
Listing 1 shows a multiplication expression. 6 * 7 Listing 1: Multiplication expression
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.