Bootstrap Topic-Wise Practice Lab
Practice Bootstrap 5 topics individually with coding questions, sample programs, and expected outputs.
1. Containers
Practice question: Create a fixed responsive container and a full-width container.
<div class="container bg-primary text-white p-3 mb-2">
Fixed Responsive Container
</div>
<div class="container-fluid bg-success text-white p-3">
Full Width Container
</div>
Output
2. Grid System
Practice question: Divide a row into three equal columns.
<div class="row g-2">
<div class="col-md-4">Column 1</div>
<div class="col-md-4">Column 2</div>
<div class="col-md-4">Column 3</div>
</div>
Output
3. Typography
Practice question: Display different heading sizes and muted text.
<h1 class="display-4">Bootstrap Heading</h1>
<p class="lead">This is lead text.</p>
<p class="text-muted">This is muted text.</p>
Output
Bootstrap Heading
This is lead text.
This is muted text.
4. Tables
Practice question: Create a striped table with bordered cells.
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr><th>Name</th><th>Marks</th></tr>
</thead>
<tbody>
<tr><td>Amit</td><td>85</td></tr>
<tr><td>Priya</td><td>92</td></tr>
</tbody>
</table>
Output
| Name | Marks |
|---|---|
| Amit | 85 |
| Priya | 92 |
5. List Groups
Practice question: Display a list of courses using a Bootstrap list group.
<ul class="list-group">
<li class="list-group-item active">Java</li>
<li class="list-group-item">Python</li>
<li class="list-group-item">.NET</li>
</ul>
Output
- Java
- Python
- .NET
6. Forms
Practice question: Create a contact form with name, email, and a submit button.
<label class="form-label">Name</label>
<input class="form-control" placeholder="Enter name">
<label class="form-label mt-3">Email</label>
<input type="email" class="form-control"
placeholder="Enter email">
<button class="btn btn-primary mt-3">Submit</button>
Output
7. Buttons
Practice question: Display primary, success, danger, and warning buttons.
<button class="btn btn-primary">Primary</button>
<button class="btn btn-success">Success</button>
<button class="btn btn-danger">Delete</button>
<button class="btn btn-warning">Warning</button>
Output
8. Button Groups
Practice question: Group three view options into a single control.
<div class="btn-group" role="group">
<button class="btn btn-outline-primary">Day</button>
<button class="btn btn-outline-primary">Week</button>
<button class="btn btn-outline-primary">Month</button>
</div>
Output
9. Image Styling
Practice question: Make an image responsive and give it rounded corners.
<img src="/images/course.jpg"
class="img-fluid rounded"
alt="Course">
/images/course.jpg with an
existing image path in your project to test it.
10. Cards
Practice question: Create a course card with a title, description, and button.
<div class="card">
<div class="card-body">
<h5 class="card-title">Web Development</h5>
<p class="card-text">Learn HTML, CSS and Bootstrap.</p>
<button class="btn btn-primary">Learn More</button>
</div>
</div>
Output
Web Development
Learn HTML, CSS and Bootstrap.
11. Navbar
Practice question: Create a navigation bar with Home, Courses, and Contact links.
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">My Website</a>
<div class="navbar-nav">
<a class="nav-link active" href="#">Home</a>
<a class="nav-link" href="#">Courses</a>
<a class="nav-link" href="#">Contact</a>
</div>
</div>
</nav>
Output
12. Alerts
Practice question: Display success, warning, and danger notifications.
<div class="alert alert-success">Saved successfully!</div>
<div class="alert alert-warning">Please verify your details.</div>
<div class="alert alert-danger">Something went wrong.</div>
Output
13. Badges
Practice question: Show a notification count and a course status.
<h5>Notifications
<span class="badge bg-danger">4</span>
</h5>
<span class="badge bg-success">Completed</span>
Output
Notifications 4
Completed14. Progress Bars
Practice question: Show a project completion percentage of 60%.
<div class="progress">
<div class="progress-bar" role="progressbar"
style="width: 60%;"
aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100">60%</div>
</div>
Output
15. Pagination
Practice question: Create pagination controls for a student list.
<nav aria-label="Student pages">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link" href="#">Previous</a>
</li>
<li class="page-item active">
<a class="page-link" href="#">1</a>
</li>
<li class="page-item">
<a class="page-link" href="#">2</a>
</li>
</ul>
</nav>
Output
16. Dropdown
Practice question: Create a dropdown menu for course categories.
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle"
data-bs-toggle="dropdown">
Select Course
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Java</a></li>
<li><a class="dropdown-item" href="#">Python</a></li>
</ul>
</div>
Output
17. Accordion
Practice question: Display FAQs with collapsible answers.
<div class="accordion" id="practiceFaq">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button"
data-bs-toggle="collapse"
data-bs-target="#faqAnswer">
What is Bootstrap?
</button>
</h2>
<div id="faqAnswer" class="accordion-collapse collapse show"
data-bs-parent="#practiceFaq">
<div class="accordion-body">
Bootstrap is a front-end framework.
</div>
</div>
</div>
</div>
Output
18. Modal
Practice question: Open a popup dialog when the user clicks a button.
<button class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#practiceDialog">
Open Dialog
</button>
Output
19. Nav Tabs
Practice question: Create tabs to switch between course information sections.
<ul class="nav nav-tabs">
<li class="nav-item">
<button class="nav-link active"
data-bs-toggle="tab"
data-bs-target="#tabOverview">
Overview
</button>
</li>
</ul>
Output
20. Toast Notification
Practice question: Show a small notification when the user clicks a button.
<button class="btn btn-primary" id="showPracticeToast">
Show Notification
</button>
Output
Your Assignment
- Create a responsive employee details table.
- Build a login form using Bootstrap validation classes.
- Create a four-card dashboard using the grid system.
- Create tabs for Course Overview, Syllabus, and Fees.
- Build an FAQ accordion with five questions.