A Bootstrap alert variant is a style option that changes the color and appearance of an alert box to indicate different meanings like success, warning, danger, or info.
Click to reveal answer
beginner
Name three common Bootstrap alert variants and their typical meanings.
Success: Green color, means a positive action or success. Warning: Yellow/orange color, means caution or something to watch. Danger: Red color, means an error or serious problem.
Click to reveal answer
beginner
How do you add a success alert in Bootstrap using HTML?
Use a <div> with classes alert and alert-success. Example:
What role attribute should you add to Bootstrap alerts for accessibility?
Add role="alert" to the alert container. This helps screen readers announce the alert message immediately.
Click to reveal answer
intermediate
Can Bootstrap alert variants be customized with your own colors?
Yes, you can customize alert colors by overriding Bootstrap CSS variables or adding your own CSS styles to change the background and text colors.
Click to reveal answer
Which Bootstrap class creates a red alert box?
Aalert-info
Balert-warning
Calert-success
Dalert-danger
✗ Incorrect
The class alert-danger creates a red alert box indicating danger or error.
What is the purpose of the role="alert" attribute in Bootstrap alerts?
ATo style the alert with colors
BTo help screen readers announce the alert immediately
CTo add animation effects
DTo make the alert dismissible
✗ Incorrect
The role="alert" attribute helps screen readers announce the alert message right away for accessibility.
Which alert variant is typically yellow or orange in Bootstrap?
Aalert-warning
Balert-primary
Calert-success
Dalert-secondary
✗ Incorrect
The alert-warning variant is usually yellow or orange to signal caution.
How do you make a Bootstrap alert dismissible (able to close)?
AAdd class <code>alert-dismissible</code> and include a close button
BAdd class <code>alert-close</code>
CAdd class <code>alert-hide</code>
DAdd class <code>alert-remove</code>
✗ Incorrect
Adding alert-dismissible and a close button allows users to close the alert.
Which Bootstrap alert variant is used for informational messages?
Aalert-success
Balert-danger
Calert-info
Dalert-warning
✗ Incorrect
The alert-info variant is used for informational messages and usually has a blue color.
Explain how Bootstrap alert variants help users understand different types of messages on a website.
Think about how colors like green or red make you feel about the message.
You got /4 concepts.
Describe how to create an accessible alert in Bootstrap that can be read by screen readers.
Accessibility means everyone can understand the message, including people using special tools.
You got /4 concepts.
Practice
(1/5)
1. Which Bootstrap class would you use to create a green alert box indicating success? <div class="alert ?" role="alert">Success message</div>
easy
A. alert-warning
B. alert-success
C. alert-danger
D. alert-info
Solution
Step 1: Understand Bootstrap alert color meanings
Bootstrap uses alert-success for green alerts indicating success.
Step 2: Match the class to the color green
The alert-success class applies green background and border to the alert box.
Final Answer:
alert-success -> Option B
Quick Check:
Green alert = alert-success [OK]
Hint: Success alerts are always green with alert-success class [OK]
Common Mistakes:
Using alert-danger for success (red color)
Using alert-warning which is yellow
Confusing alert-info with success
2. Which of the following is the correct syntax to create a Bootstrap alert with a blue background for informational messages? <div class="alert ?" role="alert">Info message</div>
easy
A. alert-light
B. alert-primary
C. alert-info
D. alert-dark
Solution
Step 1: Identify the class for informational alerts
Bootstrap uses alert-info for blue background alerts that show info messages.
Step 2: Confirm syntax correctness
The class alert-info is the correct class to apply blue styling for info alerts.
Final Answer:
alert-info -> Option C
Quick Check:
Info alert = alert-info [OK]
Hint: Info alerts use alert-info class for blue color [OK]
Common Mistakes:
Using alert-primary which is darker blue but not info
Using alert-light which is very pale
Using alert-dark which is black/dark gray
3. What color will the alert box have when using this code?
A. The alert-danger class does not exist in Bootstrap
B. Class name should be danger instead of alert-danger
C. The alert class is missing, only alert-danger is present
D. Missing role="alert" attribute for accessibility
Solution
Step 1: Check the alert classes used
The code uses both alert and alert-danger classes correctly, so the styling should apply.
Step 2: Identify missing accessibility attribute
Bootstrap recommends adding role="alert" for screen readers to recognize the alert properly.
Final Answer:
Missing role="alert" attribute for accessibility -> Option D
Quick Check:
Alerts need role="alert" for proper behavior [OK]
Hint: Always add role="alert" for Bootstrap alerts [OK]
Common Mistakes:
Thinking alert-danger class is wrong
Forgetting to add alert base class
Assuming alert-danger does not exist
5. You want to create a Bootstrap alert that changes color based on a variable status in JavaScript. Which approach correctly applies the alert variant class dynamically?