0
0
Bootsrapmarkup~20 mins

Dropdown button basics in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dropdown Mastery Badge
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 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>
AA blue button labeled 'Choose an option' with a downward arrow. The dropdown menu is hidden until clicked.
BA list of three options visible on the page with no button.
CA red button labeled 'Choose an option' with no dropdown functionality.
DA blue button labeled 'Choose an option' with the dropdown menu always visible below it.
Attempts:
2 left
💡 Hint
Think about how Bootstrap dropdown buttons behave by default before interaction.
accessibility
intermediate
2: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?
Adata-toggle="dropdown"
Baria-expanded="false"
Crole="button"
Dtabindex="-1"
Attempts:
2 left
💡 Hint
Screen readers need to know if the dropdown is open or closed.
📝 Syntax
advanced
2: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?
AThe dropdown-menu must be a <div> instead of <ul>
BIncorrect class name on button (should be btn-primary)
CThe aria-expanded attribute must be true initially
DMissing Bootstrap JavaScript bundle inclusion
Attempts:
2 left
💡 Hint
Bootstrap dropdowns need JavaScript to toggle visibility.
selector
advanced
2: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?
A.dropdown > button.dropdown-toggle
B.dropdown .dropdown-menu button
C.dropdown-menu + button
Dbutton.btn-info
Attempts:
2 left
💡 Hint
Look for a selector that targets a button with class dropdown-toggle directly inside .dropdown.
layout
expert
2: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?
AWrap the button in a flex container with justify-content-center
BAdd style="width: 100px" to the button element
CAdd class w-100 to the button element
DAdd class dropdown-menu-end to the dropdown-menu
Attempts:
2 left
💡 Hint
Bootstrap has utility classes for width control.