Challenge - 5 Problems
Focus Mastery in Modals
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateWhy is focus management important in modals?
When a modal dialog opens, why should the keyboard focus be moved inside the modal?
Attempts:
2 left
💡 Hint
Think about users who navigate with keyboard only.
✗ Incorrect
Moving focus inside the modal ensures that keyboard users can only interact with the modal content, preventing confusion and improving accessibility.
📝 Syntax
intermediateWhich Bootstrap attribute controls focus trapping in modals?
Bootstrap modals automatically trap focus inside the modal. Which attribute or option enables this behavior?
Attempts:
2 left
💡 Hint
Look for an attribute related to focus.
✗ Incorrect
The data-bs-focus="true" attribute ensures that Bootstrap traps focus inside the modal when it opens.
❓ rendering
advancedWhat happens visually when focus is trapped inside a Bootstrap modal?
When a Bootstrap modal traps focus, what will a keyboard user see or experience?
Attempts:
2 left
💡 Hint
Focus trapping means cycling inside the modal.
✗ Incorrect
Focus trapping means keyboard navigation cycles only through modal elements, preventing focus from moving to background content.
❓ selector
advancedWhich CSS selector helps style the focused element inside a modal?
To visually indicate which element has keyboard focus inside a modal, which CSS selector should you use?
Attempts:
2 left
💡 Hint
Focus means keyboard selection, not mouse hover.
✗ Incorrect
The :focus selector targets elements that currently have keyboard focus, allowing styling to show which element is active.
❓ accessibility
expertHow should focus behave when a Bootstrap modal closes?
After closing a modal, where should the keyboard focus return to maintain good accessibility?
Attempts:
2 left
💡 Hint
Think about where the user was before opening the modal.
✗ Incorrect
Returning focus to the element that triggered the modal helps users continue their workflow without confusion.
