0
0
Bootsrapmarkup~20 mins

Badge component in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bootstrap Badge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2: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>
AA small blue pill-shaped label with white text 'New'
BA large red square with black text 'New'
CA plain text 'New' with no background or styling
DA button with the text 'New' and a blue border
Attempts:
2 left
💡 Hint
Bootstrap badges use the class 'badge' and color classes like 'bg-primary' for background color.
selector
intermediate
2: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?
A.badge nav
Bnav .badge
Cnav > badge
D.nav .badge
Attempts:
2 left
💡 Hint
Think about how to select elements with class inside a parent element.
🧠 Conceptual
advanced
2: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?
Arole="status"
Brole="button"
Crole="alert"
Drole="presentation"
Attempts:
2 left
💡 Hint
The badge updates dynamically and should inform users politely without interrupting.
layout
advanced
2: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>
AUse <code>float: right</code> on badge inside button
BUse <code>position: fixed</code> on badge with top and right set to 0
CUse <code>display: inline-block</code> on badge and <code>margin-left: auto</code> on button
DUse <code>position-relative</code> on button and <code>position-absolute top-0 start-100 translate-middle</code> on badge
Attempts:
2 left
💡 Hint
Bootstrap utilities for positioning use relative and absolute classes with translation helpers.
📝 Syntax
expert
2: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>
AThe badge text is not visible because of missing color classes
BSyntaxError due to invalid attribute usage
CNo error, but role="button" misleads screen readers since badge is not interactive
DThe badge does not appear because <code>role="button"</code> disables styling
Attempts:
2 left
💡 Hint
Consider semantic meaning and accessibility roles for non-interactive elements.