Bootstrap Cards HTML Code Examples

Bootstrap, a popular CSS framework, simplifies responsive web development by providing pre-defined classes for common HTML elements. One of its most versatile components is the card, used to display content in a flexible and attractive manner. Let's explore how to create Bootstrap cards using HTML code.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Before we dive into the code, ensure you have included the Bootstrap CSS and JavaScript libraries in your project. You can include the CDN links in your HTML file's head section like this: `` and ``.

Bootstrap Card Example
Bootstrap Card Example

Basic Bootstrap Card

A basic Bootstrap card consists of a container with the class `.card`. It can contain various elements like text, images, and buttons. Here's a simple example:

an image of a computer screen with text
an image of a computer screen with text

<div class="card" style="width: 18rem;"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>

Card Variations

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Bootstrap offers several variations of the card component. You can change the background color, text color, and border color using the `.bg-*`, `.text-*`, and `.border-*` classes, respectively. Here's an example:

<div class="card bg-primary text-white border-primary mb-3" style="max-width: 18rem;"> <div class="card-header">Header</div> <div class="card-body"> <h5 class="card-title">Primary card title</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> </div> </div>

Card Groups

Bootstrap card design with hover effect
Bootstrap card design with hover effect

You can group cards together using the `.card-group` class. This is useful when you want to display multiple cards side by side. Here's an example:

<div class="card-group"> <div class="card"> <img src="..." class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Card title</h5> <p class="card-text">This is some text within a card body.</p> <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> </div> </div> <div class="card">...</div> <div class="card">...</div> </div>

Responsive Cards

10+ Bootstrap Cards (latest collection)
10+ Bootstrap Cards (latest collection)

Bootstrap cards are responsive by default. They will stack on top of each other on smaller screens and display side by side on larger screens. You can also control the responsiveness of cards using the grid system. Here's an example:

<div class="card-deck"> <div class="card">...</div> <div class="card">...</div> <div class="card">...</div> </div>

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
the wordpress website is designed to look like it has many different colors and shapes
the wordpress website is designed to look like it has many different colors and shapes
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Criando Controle Deslizante de Cartão Com HTML CSS e JS
Criando Controle Deslizante de Cartão Com HTML CSS e JS
CSS Card Design
CSS Card Design
CSS Notes for Beginners (Easy + Quick Guide) 🎨
CSS Notes for Beginners (Easy + Quick Guide) 🎨
#CSS Animations Tips and Tricks
#CSS Animations Tips and Tricks
CSS Gradient Card Border Animation
CSS Gradient Card Border Animation
CSS card swiped effect
CSS card swiped effect
CSS 3D cards
CSS 3D cards

Card Deck

The `.card-deck` class creates a deck of cards that are responsive and stack on smaller screens. Here's an example:

<div class="card-deck"> <div class="card">...</div> <div class="card">...</div> <div class="card">...</div> </div>

Incorporating Bootstrap cards into your web project can significantly enhance the user experience and improve the visual appeal of your website. With these examples, you're well on your way to creating engaging and responsive card layouts. Happy coding!