A list group is a flexible and powerful component for displaying a series of content. It is often used to show lists of items with consistent styling and spacing.
Click to reveal answer
beginner
How do you add a badge to a list group item in Bootstrap?
You add a <span> element with the class badge inside the list group item. The badge usually shows a count or label aligned to the right.
Click to reveal answer
intermediate
What Bootstrap class aligns badges to the right inside list group items?
Flex utilities like d-flex justify-content-between align-items-center on the list-group-item align badges to the right. The badge is styled with classes like badge bg-primary rounded-pill.
Click to reveal answer
beginner
Why use badges in list groups?
Badges provide extra information like counts, statuses, or labels next to list items. They help users quickly see important details without extra text.
Click to reveal answer
beginner
Show the basic HTML structure for a Bootstrap list group with badges.
Use <ul class='list-group'> with <li class='list-group-item d-flex justify-content-between align-items-center'>. Inside each li, add a <span class='badge bg-primary rounded-pill'> for the badge.
Click to reveal answer
Which Bootstrap class is used to create a list group?
Acontainer
Blist-group
Cbadge
Dcard
✗ Incorrect
The class list-group creates a list group container in Bootstrap.
What class combination styles a badge with a pill shape and primary color?
Abadge text-primary rounded
Bbadge bg-secondary rounded-circle
Cbadge bg-primary rounded-pill
Dbadge bg-danger
✗ Incorrect
Use badge bg-primary rounded-pill to get a blue pill-shaped badge.
How do you align a badge to the right inside a list group item?
AUse flex utilities like <code>d-flex justify-content-between</code> on the list item
BAdd <code>text-right</code> to the badge
CUse <code>float-right</code> on the badge
DAdd <code>align-right</code> to the list group
✗ Incorrect
Bootstrap uses flexbox with d-flex justify-content-between on the list item to space content and badge apart.
Which HTML element is typically used for badges inside list groups?
A<section>
B<div>
C<p>
D<span>
✗ Incorrect
Badges are usually <span> elements for inline styling.
What is the main purpose of badges in list groups?
AShow extra info like counts or labels
BAdd images
CCreate links
DChange background color
✗ Incorrect
Badges highlight important info such as numbers or statuses next to list items.
Explain how to create a Bootstrap list group with badges that show counts on the right side.
Think about using flexbox classes to space the badge and item text.
You got /5 concepts.
Describe why badges are useful in list groups and how they improve user experience.
Consider how badges add meaning without extra words.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using a list group with badges in Bootstrap?
easy
A. To create horizontal navigation menus
B. To create image galleries
C. To add background colors to buttons
D. To display a vertical list of items with extra info like counts on the right
Solution
Step 1: Understand list groups
List groups in Bootstrap organize items vertically for easy reading.
Step 2: Role of badges
Badges add extra info like counts or statuses aligned to the right of list items.
Final Answer:
To display a vertical list of items with extra info like counts on the right -> Option D
Quick Check:
List groups + badges = vertical list with extra info [OK]
Hint: Badges show counts or status next to list items [OK]
Common Mistakes:
Confusing badges with navigation tabs
Thinking list groups are for images
Using badges for background colors
2. Which Bootstrap class combination correctly aligns a badge to the right inside a list group item?
easy
A. list-group-item float-left
B. list-group-item text-center
C. list-group-item d-flex justify-content-between align-items-center
D. list-group-item badge-end
Solution
Step 1: Identify flex classes for alignment
Using d-flex justify-content-between align-items-center makes the list item a flex container that spaces content horizontally and centers vertically.
Step 2: Confirm badge alignment
This combination pushes the badge to the right side automatically.
Final Answer:
list-group-item d-flex justify-content-between align-items-center -> Option C
Quick Check:
Flex + justify-content-between aligns badge right [OK]
Hint: Use flex and justify-content-between for right badge alignment [OK]
Common Mistakes:
Using float classes which Bootstrap 5 discourages
Using text-center which centers content
Using non-existent badge-end class
3. What will be the visual result of this code snippet?
A. Incorrect badge color class; should be bg-primary
B. Missing flex classes to align badge right
C. Badge should be outside the list item
D. List group should be a div, not ul
Solution
Step 1: Check badge color class
Bootstrap 5 uses bg-primary for badge background color, not badge-primary.
Step 2: Confirm badge alignment
While flex classes help alignment, the main error is the wrong badge color class.
Final Answer:
Incorrect badge color class; should be bg-primary -> Option A
Quick Check:
Use bg-primary for badge color in Bootstrap 5 [OK]
Hint: Use bg-primary, not badge-primary, for badge colors [OK]
Common Mistakes:
Using old Bootstrap 4 badge classes
Forgetting flex classes but that is not an error
Placing badge outside list item
5. You want to create a list group showing tasks with badges indicating priority: High (red), Medium (yellow), Low (green). Which badge classes correctly apply these colors in Bootstrap 5?
hard
A. badge-danger for High, badge-warning for Medium, badge-success for Low
B. bg-danger for High, bg-warning for Medium, bg-success for Low
C. text-danger for High, text-warning for Medium, text-success for Low
D. bg-primary for High, bg-secondary for Medium, bg-info for Low
Solution
Step 1: Identify correct badge background classes
Bootstrap 5 uses bg-danger for red, bg-warning for yellow, and bg-success for green backgrounds.
Step 2: Confirm badge class usage
Badges require bg-* classes, not badge-* or text-* for background colors.
Final Answer:
bg-danger for High, bg-warning for Medium, bg-success for Low -> Option B
Quick Check:
Use bg-danger/warning/success for badge colors [OK]
Hint: Use bg-danger/warning/success for red/yellow/green badges [OK]
Common Mistakes:
Using old badge-danger classes
Using text color classes instead of background
Mixing unrelated color classes
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.