Challenge - 5 Problems
Bootstrap Badge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
Rendering a Bootstrap list group with badges
What will be the visual output of this Bootstrap list group code snippet?
Bootsrap
<ul class="list-group"> <li class="list-group-item d-flex justify-content-between align-items-center"> Messages <span class="badge bg-primary rounded-pill">14</span> </li> <li class="list-group-item d-flex justify-content-between align-items-center"> Notifications <span class="badge bg-secondary rounded-pill">2</span> </li> </ul>
Attempts:
2 left
💡 Hint
Look at the classes used for layout and badge styling.
✗ Incorrect
The 'd-flex justify-content-between align-items-center' classes create a horizontal space between text and badge, placing the badge on the right. The 'badge bg-primary rounded-pill' creates a blue pill-shaped badge. The list is vertical by default.
❓ selector
intermediate1:30remaining
CSS selector for badge styling in Bootstrap list groups
Which CSS selector correctly targets the badge elements inside a Bootstrap list group item?
Attempts:
2 left
💡 Hint
Think about the badge being a direct child of the list group item.
✗ Incorrect
In Bootstrap, badges are direct children of list-group-item elements, so the selector '.list-group-item > .badge' correctly targets them.
🧠 Conceptual
advanced2:00remaining
Accessibility considerations for badges in list groups
Which practice improves accessibility for badges in Bootstrap list groups?
Attempts:
2 left
💡 Hint
Think about users who rely on screen readers.
✗ Incorrect
Adding aria-label to badges helps screen readers understand the badge's meaning. Using only color or hiding badges from screen readers reduces accessibility.
❓ layout
advanced2:00remaining
Effect of removing flex classes on badge alignment
What happens if you remove the 'd-flex justify-content-between align-items-center' classes from the list group item containing a badge?
Bootsrap
<ul class="list-group"> <li class="list-group-item"> Messages <span class="badge bg-primary rounded-pill">14</span> </li> </ul>
Attempts:
2 left
💡 Hint
Consider how flexbox controls horizontal spacing and alignment.
✗ Incorrect
Without flexbox classes, the badge stays inline after the text with no space pushing it to the right, so it aligns baseline next to the text.
📝 Syntax
expert2:30remaining
Correct Bootstrap badge class for a pill-shaped badge
Which option uses the correct Bootstrap 5 class combination to create a pill-shaped badge with a green background inside a list group item?
Attempts:
2 left
💡 Hint
Check Bootstrap 5 badge color and shape classes.
✗ Incorrect
In Bootstrap 5, 'bg-success' sets green background, and 'rounded-pill' creates pill shape. 'badge-success' and 'pill-rounded' are Bootstrap 4 or invalid classes. 'rounded-circle' makes a circle, not a pill.