Challenge - 5 Problems
Dropdown Mastery Badge
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 dropdown button code?
Given the following HTML code using Bootstrap 5, what will the user see when the page loads?
Bootsrap
<div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Choose an option </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Option 1</a></li> <li><a class="dropdown-item" href="#">Option 2</a></li> <li><a class="dropdown-item" href="#">Option 3</a></li> </ul> </div>
Attempts:
2 left
💡 Hint
Think about how Bootstrap dropdown buttons behave by default before interaction.
✗ Incorrect
Bootstrap dropdown buttons show a button with a label and a downward arrow. The menu is hidden initially and appears only when the button is clicked.
❓ accessibility
intermediate2:00remaining
Which attribute improves accessibility for this Bootstrap dropdown button?
Consider this button element in a Bootstrap dropdown:
Which attribute should be added to improve screen reader accessibility?
Attempts:
2 left
💡 Hint
Screen readers need to know if the dropdown is open or closed.
✗ Incorrect
The aria-expanded attribute tells assistive technologies whether the dropdown is currently expanded or collapsed, improving accessibility.
📝 Syntax
advanced2:00remaining
What error occurs with this dropdown button code?
Examine this snippet:
But the dropdown does not open when clicked. What is the most likely cause?
Attempts:
2 left
💡 Hint
Bootstrap dropdowns need JavaScript to toggle visibility.
✗ Incorrect
Without including Bootstrap's JavaScript bundle, the dropdown toggle won't work because the click event is not handled.
❓ selector
advanced2:00remaining
Which CSS selector targets only the dropdown toggle button inside a dropdown?
You want to style only the button that toggles the dropdown inside this structure:
Which CSS selector correctly targets only the toggle button?
Attempts:
2 left
💡 Hint
Look for a selector that targets a button with class dropdown-toggle directly inside .dropdown.
✗ Incorrect
The selector '.dropdown > button.dropdown-toggle' selects any button with class dropdown-toggle that is a direct child of an element with class dropdown.
❓ layout
expert2:00remaining
How to make a Bootstrap dropdown button full width inside a container?
You have this dropdown button inside a container:
You want the button to stretch to fill the container's width responsively. Which is the best way?
Attempts:
2 left
💡 Hint
Bootstrap has utility classes for width control.
✗ Incorrect
The w-100 class sets width to 100% making the button fill the container's width responsively.