Master Bootstrap From Scratch

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

Bootstrap Practical Examples

Practice Bootstrap 5 components with real-world examples and interactive demonstrations.

Introduction

In this section, you will combine Bootstrap components to build practical user interfaces. You will practice cards, buttons, forms, alerts, navigation, accordions and responsive layouts through examples inspired by real websites.

Learning Objectives

  • Combine multiple Bootstrap components in one page.
  • Create responsive layouts using the grid system.
  • Build forms with validation feedback.
  • Display notifications and interactive content.
  • Apply Bootstrap to real-world website scenarios.

Practical Learning Flow

Step 1
Learn

Understand the component.

Step 2
Practice

Write and understand the code.

Step 3
Test

Interact with the output.

Step 4
Build

Apply the concepts to a project.

1. Course Listing Cards

Real-life use: A training institute website can display courses using cards. Each card contains the course name, description and an action button.

Program Code
<div class="row g-3">

    <div class="col-md-4">
        <div class="card h-100 shadow-sm">
            <div class="card-body">
                <h5 class="card-title">Java Full Stack</h5>
                <p class="card-text">
                    Learn Java, Spring Boot and databases.
                </p>
                <a href="#" class="btn btn-primary">
                    View Course
                </a>
            </div>
        </div>
    </div>

</div>
Program Output
Java Full Stack

Learn Java, Spring Boot and databases.

Python Full Stack

Learn Python, web development and databases.

.NET Full Stack

Learn C#, ASP.NET Core and SQL Server.

2. Student Enquiry Form

Real-life use: Students can enter their contact details and select a course to request information. Bootstrap form classes provide consistent styling.

Program Code
<form>
    <div class="mb-3">
        <label class="form-label" for="studentName">
            Student Name
        </label>
        <input type="text"
               id="studentName"
               class="form-control"
               required>
    </div>

    <div class="mb-3">
        <label class="form-label" for="course">
            Select Course
        </label>
        <select id="course" class="form-select" required>
            <option value="">Choose a course</option>
            <option>Java Full Stack</option>
            <option>.NET Full Stack</option>
        </select>
    </div>

    <button type="submit" class="btn btn-success">
        Submit Enquiry
    </button>
</form>
Program Output

Demo only: this form validates the input in the browser. It does not send or save data to a server.

3. Success and Error Alerts

Real-life use: Display success feedback after a completed action or an error message when the action cannot be completed.

Program Code
<div class="alert alert-success" role="alert">
    Enquiry submitted successfully!
</div>

<div class="alert alert-danger" role="alert">
    Please correct the errors and try again.
</div>
Program Output

4. Responsive Grid Layout

Real-life use: Bootstrap's grid can display three columns on desktop and stack them on smaller screens. Here, col-md-4 makes each column occupy one-third of the row at medium widths and above.

Program Code
<div class="row g-3">
    <div class="col-12 col-md-4">
        <div class="p-3 border rounded">Column 1</div>
    </div>

    <div class="col-12 col-md-4">
        <div class="p-3 border rounded">Column 2</div>
    </div>

    <div class="col-12 col-md-4">
        <div class="p-3 border rounded">Column 3</div>
    </div>
</div>
Program Output
Column 1

Course Details

Column 2

Student Reviews

Column 3

Contact Details

5. Frequently Asked Questions

Real-life use: An FAQ section helps visitors find answers about course duration, syllabus and training modes without displaying all answers at once.

Program Code
<div class="accordion" id="faqExample">
    <div class="accordion-item">
        <h2 class="accordion-header">
            <button class="accordion-button collapsed"
                    type="button"
                    data-bs-toggle="collapse"
                    data-bs-target="#faqAnswer">
                Are online classes available?
            </button>
        </h2>

        <div id="faqAnswer"
             class="accordion-collapse collapse"
             data-bs-parent="#faqExample">
            <div class="accordion-body">
                Online classes may be available depending on the course.
            </div>
        </div>
    </div>
</div>
Program Output

Online classes may be available depending on the course and batch schedule.

Project exercises help students practice concepts and improve their development skills.

6. Mini Project: Training Institute Website

Now combine the examples above to create a simple training institute landing page.

Project Requirements
  • Display a course listing using Bootstrap cards.
  • Create a student enquiry form.
  • Use success and error feedback.
  • Arrange content using a responsive grid.
  • Add an FAQ accordion.
Project Flow
Browse Courses
Select Course
Submit Enquiry
Show Feedback
Important: This page demonstrates the frontend. A production application needs server-side validation, a controller action and database integration to save real enquiries.

Common Mistakes

  • Forgetting the Bootstrap JavaScript bundle for interactive components.
  • Using duplicate IDs in forms and accordion panels.
  • Ignoring responsive grid classes.
  • Using buttons that do not perform their intended action.
  • Assuming frontend validation replaces server-side validation.

Summary

  • Cards organize course information.
  • Forms collect user input.
  • Alerts display feedback messages.
  • The grid creates responsive layouts.
  • Accordions organize expandable FAQ content.
  • Real applications need backend validation and data handling.