Bootstrap5 Cards
The Bootstrap 5 Card component is a powerful and flexible container for displaying various content, such as text, images, lists, buttons, etc.
The Card component has been improved and enhanced in Bootstrap 5, providing more customization options and more flexible layout methods.
Card components are very common in UI design, especially suitable for blogs, social media, dashboards and other content display pages.
Ba
sic Structure
Bootstrap 5's Card component includes the following common elements:
.card: the outermost container of the card..card-body: the main content area of the card..card-title: the title section of the card..card-text: the text section of the card..card-img-topor.card-img-bottom: the image at the top or bottom of the card.
Card Style Class Descriptions:
| Class Names | Description | Example Usage |
|---|---|---|
.card |
The card's container class, used to wrap the entire card. | |
.card-body |
A container that holds the card content, usually used to place text, titles, etc. | |
.card-title |
The card title class, usually containing the card's main title. | |
.card-text |
The card text class, usually containing the card's body content. | |
.card-img-top |
The card top image class, usually used to display an image at the top of the card. | |
.card-img-bottom |
The card bottom image class, usually used to display an image at the bottom of the card. | |
.card-header |
The card's header area, used to place titles or other content. | |
.card-footer |
The card's footer area, used to place additional information or action buttons, etc. | |
.card-link |
Used to create links within the card. | Card link |
.card-deck |
has been deprecated in Bootstrap 5, use row and col instead. |
|
.card-group |
has been deprecated in Bootstrap 5, use row and col instead. |
|
.card-columns |
Use a multi-column layout, with cards arranged in a flowing layout. | |
.card-subtitle |
The card's subtitle, usually displayed below the title. | |
.card-img-overlay |
Overlay a content layer on the card image, often used to display text or other elements. | |
Simple Cards
We can create a simple card through Bootstrap5's .card and .card-body classes. A card can contain a header, content, footer and various color settings, as shown in the example below:

Example
<div class="card">
<div class="card-body">Simple Cards
div
div
Try it »
Header and Footer
The .card-header class is used to create the card header style, and the .card-footer class is used to create the card footer style:

Example
<div class="card">
<div class="card-header" Header div>
<div class="card-body" Content div>
<div class="card-footer" Footer div div>Try it »
Cards in Multiple Colors
Bootstrap 5 provides a variety of card background color classes: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light.

Example
<div class="container">
<h2>Cards in Multiple Colors
h2
<div class="card">
<div class="card-body">Basic Card
div
div
<br>
<div class=">card bg-primary text-white
"
<div class="card-body">Primary Card
div
div
<br>
<div class=">card bg-success text-white
"
<div class="card-body">Success Card
div
div
<br>
<div class=">card bg-info text-white
"
<div class="card-body">Info Card
div
div
<br>
<div class=">card bg-warning text-white
"
<div class="card-body">Warning Card
div
div
<br>
<div class=">card bg-danger text-white
"
<div class="card-body">Danger Card
div
div
<br>
<div class=">card bg-secondary text-white
"
<div class="card-body">Secondary Card
div
div
<br>
<div class=">card bg-dark text-white
"
<div class="card-body">Black Card
div
div
<br>
<div class=">card bg-light text-dark
"
<div class="card-body">Light Card
div
div
div
Try it »
Titles, Text and Links
We can use the .card-title class on the header element to set the card title. The .card-body class is used to set the card body content. The .card-text class is used to set the
tag in the .card-body class; if it is the last line, the bottom margin can be removed. The .card-link class is used to set the color of links.
Example
<div class="card">
<div class="card-body">
<h4 class="card-title">Card title
h4
<p class="card-text">Some example text. Some example text.
p
<a href="" class="card-link">Card link
a
<a href="" class="card-link">Another link
a
div
div
Try it »
Image Cards
We can add the to add .card-img-top (image above the text) or .card-img-bottom (image below the text) to create an image card:
Example
<div class="card" style="width:400px">
<img class="card-img-top" src="img_avatar1.png" alt=">Card image
"
<div class="card-body">
<h4 class="card-title">John Doe
h4
<p class="card-text">Some example text.
p
<a href="" class=">btn btn-primary
"
See Profile
a
div
div
Try it »
If you want to set the image as a background, you can use the .card-img-overlay class:
Example
<div class="card" style="width:500px">
<img class="card-img-top" src="img_avatar1.png" alt=">Card image
"
<div class="card-img-overlay">
<h4 class="card-title">John Doe
h4
<p class="card-text">Some example text.
p
<a href="" class=">btn btn-primary
"
See Profile
a
div
div
Try it »
