Bootstrap4 Cards
The Bootstrap 4 Card component is a flexible and powerful content container that can display various types of content, such as text, images, lists, etc.
Cards are a very common UI element in Bootstrap 4, typically used to display information, blog posts, products, or social media posts.
Basic structure
A card is composed of multiple nested elements, mainly including the following parts:
.card: the outermost container of the card..card-body: the container holding the card's content, usually used to place text, titles or other elements..card-title: the title of the card..card-text: the text content of the card..card-img-topor.card-img-bottom: used to display an image, placed at the top or bottom of the card.
Style Class Descriptions:
| Class Names | Description | Example Usage |
|---|---|---|
.card |
The card's container class, used to create the card's frame. | |
.card-body |
The card content container, used to wrap the main content section of the card. | |
.card-title |
The card title class, used to define the card's title. | |
.card-text |
The card body text class, used to add the card's text. | |
.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 header, used to place titles, tags, etc. | |
.card-footer |
The card footer, usually used to place the author, date or copyright information. | |
.card-link |
Used to create links inside a card, usually used together with other card content. | Card link |
.card-deck |
Used to arrange cards horizontally, with spacing automatically distributed evenly between cards. | |
.card-columns |
Used to create a multi-column card layout, suitable for a magazine-style layout of cards. | |
.no-gutters |
Removes the grid system's column gutters, used to eliminate the default spacing between cards. | |
.card-group |
Groups cards together, and they automatically adjust to the same height. | |
.card-img-overlay |
Overlays a content layer on the card image, usually used to display text or other elements. | |
.card-subtitle |
Card subtitle, used to display additional information below the title. | |
Simple Cards
We can create a simple card using Bootstrap4's .card and .card-body classes, as shown in the example:

Example
<div class="card">
<div class="card-body">Simple Cards
div
div
Try it »
Bootstrap4 cards are similar to the panels, thumbnails and wells in Bootstrap 3.
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 4 provides several 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">Dark 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's title. The .card-text class is used to set the card's body content. 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 »
Horizontal Cards
By combining grid and utility classes, cards can be arranged horizontally in a responsive, mobile-friendly way.
In the following example, we use .no-gutters to remove the grid spacing and use the .col-md-* class to arrange the cards horizontally at the md screen breakpoint.
Example
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Last updated 3 mins ago
Try it »
