Figures and Captions
The <figure> and <figcaption> elements group self-contained content with an optional caption, perfect for images, diagrams, code snippets, and more.
Basic Figure Usage
Loading HTML Playground...
The <figure> element:
- Groups content that's referenced from main content
- Can be moved without affecting document flow
<figcaption>provides a caption
Figure vs Regular Image
Loading HTML Playground...
Use <figure> when:
- Content is referenced from text
- Content could be moved to appendix
- You need a visible caption
Caption Placement
Loading HTML Playground...
The <figcaption> can appear:
- Before or after the figure content
- Only one figcaption per figure
Multiple Images in One Figure
Loading HTML Playground...
A single figure can contain multiple related images.
Figure for Code Snippets
Loading HTML Playground...
Figures work for any self-contained content:
- Code examples
- Diagrams
- Equations
- Poems
Figure for Quotes
Loading HTML Playground...
Styling Figures
Loading HTML Playground...
Exercise: Create an Image Gallery
Create a gallery using figures with captions:
Loading HTML Exercise...
Figures provide semantic structure for self-contained content with captions!

