B. The attribute should be data-bs-toggle="dropdown" instead of data-toggle="dropdown"
C. The button is missing the type="submit" attribute
D. The dropdown-item class should be on a button element, not a
Solution
Step 1: Check Bootstrap 5 attribute syntax
Bootstrap 5 uses data-bs-toggle="dropdown" instead of the older data-toggle="dropdown".
Step 2: Verify other parts
Button type can be "button"; dropdown-menu can be a div; a with dropdown-item is correct.
Final Answer:
The attribute should be data-bs-toggle="dropdown" instead of data-toggle="dropdown" -> Option B
Quick Check:
Bootstrap 5 uses data-bs-toggle [OK]
Hint: Use data-bs-toggle for Bootstrap 5 dropdowns [OK]
Common Mistakes:
Using old data-toggle attribute
Changing button type unnecessarily
Replacing div with ul incorrectly
Misusing dropdown-item on wrong elements
5. You want a dropdown button that shows a list of user actions and closes the menu when an item is clicked. Which Bootstrap setup ensures this behavior?
hard
A. Use button with dropdown-toggle and data-bs-toggle="dropdown", and a tags with dropdown-item inside dropdown-menu
B. Use button with dropdown-toggle but omit data-bs-toggle, and use div tags inside dropdown-menu
C. Use button with dropdown-toggle and data-toggle="dropdown", and button tags with dropdown-item inside dropdown-menu
D. Use a tag with dropdown-toggle and data-bs-toggle="dropdown", and span tags inside dropdown-menu
Solution
Step 1: Confirm correct attribute for Bootstrap 5
Bootstrap 5 requires data-bs-toggle="dropdown" for toggling dropdowns, not data-toggle.
Step 2: Check element types for accessibility and behavior
Using button elements with dropdown-toggle and a or button tags with dropdown-item inside dropdown-menu ensures keyboard accessibility and closes menu on click.
Step 3: Evaluate options
Only C uses data-bs-toggle="dropdown" (BS5 correct) with proper button.dropdown-toggle and a.dropdown-item that auto-closes the menu.
Final Answer:
Use button with dropdown-toggle and data-bs-toggle="dropdown", and a tags with dropdown-item inside dropdown-menu -> Option A
Quick Check:
data-bs-toggle + dropdown-item = auto close [OK]
Hint: data-bs-toggle + dropdown-item auto closes menu [OK]
Common Mistakes:
Using old data-toggle instead of data-bs-toggle
Omitting data-bs-toggle
Using a tag for toggle or span for items
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.