Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap Cards

Bootstrap Cards are flexible content containers used to display related information such as text, images, buttons, products, courses, profiles and other content.

Simple Explanation: A Bootstrap Card is like a small box on a webpage. We can put a title, description, buttons, lists, images and other content inside that box.

What is a Bootstrap Card?

A Bootstrap Card is a flexible and extensible content container. It is commonly used to group related content together in a visually attractive format.

Cards can contain different elements such as headings, paragraphs, images, links, buttons, lists and other Bootstrap components.

Simple Explanation: Think of a Card as a digital information box. For example, a course card can contain a course name, description and a button.

1. Basic Card

The basic Bootstrap Card is created using the .card class.

The content inside the card is normally placed inside the .card-body class.

Simple Explanation: .card creates the outer card, while .card-body contains the content.

Syntax

<div class="card">

    <div class="card-body">
        Card Content
    </div>

</div>

Example

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            Bootstrap Card
        </h5>

        <p class="card-text">
            This is a basic Bootstrap card.
        </p>

    </div>

</div>
Output:
Bootstrap Card

This is a basic Bootstrap card.

2. Card Title and Card Text

Bootstrap provides the .card-title class for the title of a card and the .card-text class for the description.

Simple Explanation: card-title is used for the main heading of the card, while card-text is used for the description or paragraph.

Example

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            Full Stack Development
        </h5>

        <p class="card-text">
            Learn frontend and backend development.
        </p>

    </div>

</div>
Output:
Full Stack Development

Learn frontend and backend development.

3. Card Header

The .card-header class creates a header section at the top of a card.

It is useful when we want to separate the heading from the main card content.

Simple Explanation: The Card Header is the top section of a card. It can contain a title, category or other information.

Example

<div class="card">

    <div class="card-header">
        Course Information
    </div>

    <div class="card-body">

        <h5 class="card-title">
            .NET Full Stack
        </h5>

        <p class="card-text">
            Learn .NET Full Stack Development.
        </p>

    </div>

</div>
Output:
Course Information
.NET Full Stack

Learn .NET Full Stack Development.

4. Card Footer

The .card-footer class creates a footer section at the bottom of a card.

Simple Explanation: A Card Footer is the bottom section of a card. It can contain dates, status, contact information or additional actions.

Example

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            Bootstrap Course
        </h5>

        <p class="card-text">
            Complete Bootstrap training.
        </p>

    </div>

    <div class="card-footer">
        Updated Today
    </div>

</div>
Output:
Bootstrap Course

Complete Bootstrap training.

5. Card with Image

Bootstrap allows us to add an image at the top of a card using the .card-img-top class.

Simple Explanation: If you want an image to appear at the top of a card, use .card-img-top.

Syntax

<div class="card">

    <img src="/Images/Boostrap/Image1.png"
         class="card-img-top"
         alt="Course Image">

    <div class="card-body">

        <h5 class="card-title">
            Bootstrap Course
        </h5>

        <p class="card-text">
            Learn Bootstrap step by step.
        </p>

    </div>

</div>
Output:
Bootstrap Course
Bootstrap Course

Learn Bootstrap step by step.

6. Card Image Bottom

The .card-img-bottom class is used when we want the image to appear at the bottom of the card.

Simple Explanation: .card-img-top puts the image at the top, while .card-img-bottom puts the image at the bottom.

Syntax

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            Bootstrap
        </h5>

        <p class="card-text">
            Bootstrap makes UI development easier.
        </p>

    </div>

    <img src="/Images/Boostrap/Image2.png"
         class="card-img-bottom"
         alt="Bootstrap Image">

</div>
Output:
Bootstrap

Bootstrap makes UI development easier.

Bootstrap Image

7. Card Links and Buttons

Cards can contain buttons and links to perform actions or navigate to another page.

Simple Explanation: For example, a course card can have a Learn More button or an Enroll Now button.

Example

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            Java Full Stack
        </h5>

        <p class="card-text">
            Learn Java Full Stack Development.
        </p>

        <a href="#" class="btn btn-primary">
            Learn More
        </a>

    </div>

</div>
Output:
Java Full Stack

Learn Java Full Stack Development.

Learn More

8. Card with List Group

Bootstrap Cards can also contain a list-group.

This is useful when a card needs to display a list of related items.

Simple Explanation: A List Group inside a Card is useful for displaying multiple related items in an organized way.

Example

<div class="card">

    <div class="card-header">
        Course Topics
    </div>

    <ul class="list-group list-group-flush">

        <li class="list-group-item">
            HTML
        </li>

        <li class="list-group-item">
            CSS
        </li>

        <li class="list-group-item">
            Bootstrap
        </li>

    </ul>

</div>
Output:
Course Topics
  • HTML
  • CSS
  • Bootstrap

9. Card Colors

Bootstrap provides contextual classes that can be used to change the background and text color of cards.

Common classes include bg-primary, bg-success, bg-warning, bg-danger and bg-dark.

Simple Explanation: We can use Bootstrap background utility classes to give different colors to cards.

Example

<div class="card bg-primary text-white">

    <div class="card-body">
        Primary Card
    </div>

</div>
Output:
Primary Card
Success Card
Warning Card

10. Card Group

The .card-group class groups multiple cards together.

Card groups are useful when we want to display related cards together in a single section.

Simple Explanation: Card Group allows multiple cards to be displayed together as one group.

Example

<div class="card-group">

    <div class="card">

        <div class="card-body">
            Java
        </div>

    </div>

    <div class="card">

        <div class="card-body">
            Python
        </div>

    </div>

    <div class="card">

        <div class="card-body">
            .NET
        </div>

    </div>

</div>
Output:
Java

Java Full Stack Development

Python

Python Full Stack Development

.NET

.NET Full Stack Development

11. Cards Using Bootstrap Grid

Bootstrap Grid can be used to create responsive card layouts.

We can use row and col-md-4 to display three cards in a row on medium and larger screens.

Simple Explanation: The Bootstrap Grid allows cards to automatically arrange themselves according to the screen size.

Example

<div class="row">

    <div class="col-md-4">

        <div class="card">

            <div class="card-body">
                Java
            </div>

        </div>

    </div>

    <div class="col-md-4">

        <div class="card">

            <div class="card-body">
                Python
            </div>

        </div>

    </div>

    <div class="col-md-4">

        <div class="card">

            <div class="card-body">
                .NET
            </div>

        </div>

    </div>

</div>
Output:
Java

Java Full Stack Development

Python

Python Full Stack Development

.NET

.NET Full Stack Development

12. Real-World CIIT Training Institute Example

Cards are very useful for displaying courses on a training institute website.

Each course can be displayed inside a separate card containing the course name, description, duration and an action button.

Simple Explanation: Here we are using normal cards only. Images are not required because the purpose of this example is to understand how course information can be arranged inside cards.

Example

<div class="card">

    <div class="card-body">

        <h5 class="card-title">
            .NET Full Stack Development
        </h5>

        <p class="card-text">
            Learn frontend, backend, database,
            API and cloud technologies.
        </p>

        <a href="#" class="btn btn-primary">
            Enroll Now
        </a>

    </div>

</div>
Output:
.NET Full Stack Development

Learn frontend, backend, database, API and cloud technologies.

Enroll Now
Java Full Stack

Learn Java, Spring Boot, REST API, database and frontend technologies.

Enroll Now
Python Full Stack

Learn Python, Django, databases, APIs and frontend development.

Enroll Now

Important Bootstrap Card Classes

Class Purpose
.card Creates the main card container.
.card-body Creates the main content area.
.card-title Styles the card title.
.card-text Styles the card description.
.card-header Creates the card header.
.card-footer Creates the card footer.
.card-img-top Places an image at the top.
.card-img-bottom Places an image at the bottom.
.card-group Groups multiple cards together.
.h-100 Makes cards use the full available height.

Common Mistakes

  • Forgetting to place the main content inside .card-body.
  • Using very large images without responsive classes.
  • Forgetting the alt attribute for images.
  • Creating cards without responsive Bootstrap columns.
  • Using fixed widths that cause horizontal scrolling on mobile devices.
  • Not keeping equal card heights when cards are displayed in a grid.

Summary

  • Bootstrap Cards are flexible containers for displaying related content.
  • .card creates the main card container.
  • .card-body contains the main card content.
  • .card-title is used for the card heading.
  • .card-text is used for card descriptions.
  • .card-header creates a card header.
  • .card-footer creates a card footer.
  • .card-img-top places an image at the top.
  • .card-img-bottom places an image at the bottom.
  • Cards can be combined with Bootstrap Grid to create responsive layouts.
  • Cards are commonly used for courses, products, profiles, services and dashboard information.