accessibility glossary

Focus Trap

A focus trap is a technique that keeps keyboard focus contained within an open modal dialog or menu, so pressing Tab cycles through only the elements inside it rather than escaping to content behind it.

When done correctly, a focus trap is essential: without one, a keyboard user tabbing through an open modal dialog would eventually tab into the page content behind it, which is invisible or inert while the dialog is open, leaving the user lost. A well-built focus trap also moves focus into the dialog when it opens and returns it to the triggering element when it closes, and always provides a way to close the dialog with the Escape key.

The term is also used negatively for the opposite bug, an unintentional focus trap, where a user gets keyboard-stuck inside a widget with no way to tab back out, which is one of the most severe accessibility failures possible.

Need help with Accessibility Remediation Services? See how halfAccessible can help.

Accessibility Remediation Services