Alerts
.alert .alert-success shows a contextual message. Add .alert-dismissible and a close button with data-bs-dismiss="alert" to let users close it.
Badges
.badge .text-bg-primary creates a small label; .rounded-pill makes it pill-shaped.
Feedback messages and labels.
✍️ 3 exercises + code challenge in this lesson.alert .alert-success shows a contextual message. Add .alert-dismissible and a close button with data-bs-dismiss="alert" to let users close it.
.badge .text-bg-primary creates a small label; .rounded-pill makes it pill-shaped.
Mastering Bootstrap Alerts & Badges helps you write clean and reliable Bootstrap code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="container py-3">
<div class="alert alert-success">Your profile was saved.</div>
<div class="alert alert-danger alert-dismissible fade show">
<strong>Error!</strong> Payment failed.
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<h4>Notifications <span class="badge text-bg-danger">4</span></h4>
<span class="badge rounded-pill text-bg-primary">New</span>
<span class="badge rounded-pill text-bg-success">Paid</span>
</div>
Check what you learned in “Bootstrap Alerts & Badges”.
Create a success alert.
<div class="alert ">Saved!</div>
Which class makes a badge pill-shaped?
Add an "alert alert-info" div with the text "New update available".
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services