Bootstrap 5 Figure
The Bootstrap 5 Figure component provides semantic HTML structure for displaying an image alongside a caption using the <figure> and <figcaption> elements. It uses the .figure, .figure-img, and .figure-caption classes to apply consistent spacing, sizing, and typography. Use it whenever an image needs contextual text that describes or credits it — such as in articles, portfolios, or product documentation.
Primary Class
.figureCommon Use Cases
- →Displaying a product photograph in an e-commerce article with a caption crediting the photographer or describing the product angle
- →Embedding a chart or data visualisation in a blog post with a caption explaining what the data represents
- →Showcasing a before-and-after image in a case study with a caption noting the date or transformation context
- →Presenting architectural or design mockups in a portfolio with captions identifying the project name, year, and client
Variants & Classes
| Variant | Description |
|---|---|
| Figure Default | Standard figure with Bootstrap's default styling. |
| Figure Responsive | Responsive variant that adapts to different screen sizes. |
Code Example
<figure class="figure">
<img
src="/img/northern-lights-iceland.jpg"
class="figure-img img-fluid rounded"
alt="Aurora borealis over a frozen lake in Iceland"
/>
<figcaption class="figure-caption text-end">
Aurora borealis, Þingvellir National Park, Iceland — March 2023
</figcaption>
</figure>Live Examples
Basic Figure
Canvas Framework Variants
The Canvas template extends Bootstrap 5 with 1,658+ component variants. Generate any of these using Canvas Builder:
- ✓Canvas Builder generated figure with custom colours
- ✓Figure with interactive states
- ✓Responsive figure for all screen sizes
Best Practices
Always add .img-fluid to prevent overflow
The .figure-img class only adds a small margin-bottom; it does not constrain width. Pair it with .img-fluid so the image scales correctly inside narrow columns or mobile viewports.
Align the caption to match the image alignment
Bootstrap's text utility classes work directly on .figure-caption. Use .text-end when your figure is right-aligned, or .text-center when the figure is centred — this keeps caption and image visually anchored together.
Use the semantic <figure> element, not a <div>
Screen readers and search engines interpret <figure> as self-contained media content. Swapping it for a <div class="figure"> breaks that semantic meaning even though the visual output looks identical.
Control figure width with column or utility classes on the parent
The figure element is block-level by default. Wrap it in a .col-md-6 or apply .w-50 .mx-auto to constrain it — the image and caption will stay proportional without extra custom CSS.