Bootstrap 5 Figure
The Bootstrap 5 Figure component provides semantic HTML structure for displaying images or illustrations alongside a caption using the <figure> and <figcaption> elements styled with .figure, .figure-img, and .figure-caption classes. It handles responsive image sizing and consistent caption typography out of the box. Use it whenever an image requires descriptive context: product shots, charts, editorial photography, or any visual that benefits from a direct label.
Bootstrap class
.figureCommon use cases
- Displaying a product photograph with a caption identifying the model name and SKU on an e-commerce detail page
- Presenting a data chart or infographic in a blog post with a caption citing the data source
- Showcasing portfolio work in a case study with a caption describing the project and year
- Embedding a map screenshot in a location or venue page with a caption noting the address or neighbourhood
Variants and classes
| Variant | Description and classes |
|---|---|
| Basic figure | Image with a caption underneath.figure + figure-img img-fluid rounded + figure-caption |
| Caption alignment | Right-aligned or centred caption.figure-caption text-end / text-center |
| Embedded media | Video or iframe with a caption.figure + ratio ratio-16x9 |
Code example
<figure class="figure">
<img
src="https://picsum.photos/seed/cb-figure/800/533"
class="figure-img img-fluid rounded"
alt="Sample landscape photo"
width="800"
height="533"
/>
<figcaption class="figure-caption text-end">
A caption describes the image and credits its source.
</figcaption>
</figure>Live examples
Basic Figure
Canvas template variants
Canvas Builder builds pages on the Canvas HTML template, which adds its own styled versions of Bootstrap 5 components. Variants you can ask for in a prompt:
- Canvas Builder generated figure with custom colours
- Figure with interactive states
- Responsive figure for all screen sizes
Best practices
Always include descriptive alt text alongside the caption
The .figure-caption is visible text for sighted users, but the img alt attribute serves screen readers. They serve different accessibility roles, so both should be present and meaningful rather than identical.
Use .text-end or .text-center on .figure-caption to align with the image edge
By default captions are left-aligned; adding .text-end mirrors the convention used in print editorial layouts and visually ties the caption to the right edge of the image.
Pair .img-fluid with a max-width utility to constrain oversized figures
Adding style="max-width: 640px;" or a utility class like .w-75 on the <figure> element itself prevents full-bleed figures in wide containers without breaking responsive scaling on small screens.
Nest figures inside Bootstrap grid columns for multi-image layouts
Wrapping each <figure class="figure"> inside a .col element lets you build side-by-side comparison figures, useful for before/after product shots or multi-angle portfolio views, without writing any custom CSS.