CHAPTER 12
Beginner
Bootstrap Alerts and Badges
Updated: May 18, 2026
5 min read
# CHAPTER 12
Bootstrap Alerts and Badges
1. Chapter Introduction
Every application needs to communicate with its users — success after form submission, errors when validation fails, warnings before deleting data, and informational tips. Bootstrap's alert, badge, and toast components handle all these notification patterns elegantly.2. Learning Objectives
- Create alerts in all 8 color variants.
- Make alerts dismissible.
- Use badge components for counts and status labels.
- Implement toast notifications.
3. Alert Components
html
4. Alerts with Links and Content
html
5. Dismissible Alerts
html
6. Badge Component
html
7. Toast Notifications
html
8. Common Mistakes
-
Forgetting
fade showon dismissible alerts: Withoutfade show, the dismiss animation won't work correctly.
-
Badge without
visually-hiddenspan: Always include<span class="visually-hidden">unread messages</span>inside counter badges for screen readers.
9. MCQs
Question 1
What class creates a dismissible alert?
Question 2
What data attribute dismisses an alert?
Question 3
Pill-shaped badge?
Question 4
Badge positioned on a button corner uses?
Question 5
Toast position (bottom-right) uses?
Question 6
Auto-hiding toast delay is configured?
Question 7
What class adds the × close button in alerts?
Question 8
Alert link class?
Question 9
role="alert" on alerts provides?
Question 10
Badge warning color with readable text?
10. Interview Questions
- Q: How do Bootstrap toasts differ from alerts?
- Q: How do you position a notification count badge on a button?