Content displayed on focus
Sometimes new content displays when the user tabs to an element or hovers their mouse cursor over it, and it disappears when the user moves focus or the cursor away from it — if this happens, the content must be dismissible and persistent in specific ways.
Meeting the Web Accessibility Standard
When content that appears and disappears upon receiving and losing focus is dismissible by the user or remains visible until the user dismisses it, this meets WCAG 2 Success Criterion 1.4.13 Content on Hover or Focus (Level AA).
Dismissible and persistent
If new content displays when an element receives keyboard focus, then the following 2 conditions must be met:
- dismissible — there is a way to dismiss or close the new content without having to move keyboard focus
- persistent — the new content remains visible until:
- the user moves focus away from the element, or
- the user otherwise dismisses it, or
- it is no longer applicable.
There are additional requirements for such new content where it appears on pointer hover.
For more on the requirements regarding content that appears on hover or focus, see:
- Exploring WCAG 2.1 — 1.4.13 Content on Hover or Focus — Knowbility
- Understanding Success Criterion 1.4.13: Content on Hover or Focus — WCAG 2 — W3C.
Exceptions
- New content that displays on focus does not need to be dismissible without moving focus if the new content:
- is about a form input error made by the user, or
- does not visually block or replace any other content.
- The accessibility requirements for content that displays on focus do not apply where the browser or user agent controls the display of this new content.