Challenge - 5 Problems
Bootstrap Badge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What is the visual output of this Bootstrap badge code?
Look at this HTML snippet using Bootstrap classes. What will you see in the browser?
Bootsrap
<span class="badge bg-primary">New</span>
Attempts:
2 left
💡 Hint
Bootstrap badges use the class 'badge' and color classes like 'bg-primary' for background color.
✗ Incorrect
The badge class creates a small label with rounded corners. The bg-primary class gives it a blue background and white text by default.
❓ selector
intermediate2:00remaining
Which CSS selector targets all Bootstrap badges inside a navigation bar?
You want to style all badges inside a
<nav> element with Bootstrap. Which selector correctly selects them?Attempts:
2 left
💡 Hint
Think about how to select elements with class inside a parent element.
✗ Incorrect
The selector nav .badge selects any element with class badge inside a nav element, at any depth.
🧠 Conceptual
advanced2:00remaining
What ARIA role should a Bootstrap badge have to improve accessibility when it shows a notification count?
You have a badge showing the number of unread messages. Which ARIA role best describes this badge for screen readers?
Attempts:
2 left
💡 Hint
The badge updates dynamically and should inform users politely without interrupting.
✗ Incorrect
The status role announces changes politely to assistive technologies without interrupting the user.
❓ layout
advanced2:00remaining
How to position a Bootstrap badge at the top-right corner of a button?
You want a small badge to appear overlapping the top-right corner of a button. Which CSS approach works best?
Bootsrap
<button type="button" class="btn btn-primary position-relative"> Notifications <span class="badge bg-danger position-absolute top-0 start-100 translate-middle">3</span> </button>
Attempts:
2 left
💡 Hint
Bootstrap utilities for positioning use relative and absolute classes with translation helpers.
✗ Incorrect
The button needs position-relative so the badge's position-absolute is relative to it. The classes top-0 start-100 translate-middle place the badge overlapping the top-right corner.
📝 Syntax
expert2:00remaining
What error does this Bootstrap badge code cause?
Examine this snippet and identify the error it causes in the browser:
Bootsrap
<span class="badge bg-primary" aria-label="New messages" role="button">New</span>
Attempts:
2 left
💡 Hint
Consider semantic meaning and accessibility roles for non-interactive elements.
✗ Incorrect
The code is valid HTML and renders correctly. However, using role="button" on a non-clickable badge can confuse assistive technology users because it suggests the element is interactive when it is not.