WCAG 2.4.7: Focus Visible
Introduction to WCAG 2.4.7 Focus Visible
WCAG (Web Content Accessibility Guidelines) 2.4.7, titled Focus Visible, is a Level AA success criterion that mandates a clear and visible indicator for any user interface component that receives keyboard focus. In essence, when a user navigates a website or application using only a keyboard (e.g., by pressing the Tab key), there must be a visible cue that clearly shows which element is currently active or 'in focus’.
This criterion ensures that users can always discern their current position on a page, allowing them to interact confidently and effectively with content and controls.
Why Focus Visible Matters for Accessibility
The absence of a visible focus indicator can render a website virtually unusable for a significant portion of the population. It’s a foundational aspect of accessible design, directly impacting user experience and navigational efficiency.
Accessibility Impact
User Groups Affected
A wide range of users benefits from clear focus indicators:
Success Criterion 2.4.7: Focus Visible (Level AA)
The official wording for this success criterion is:
2.4.7 Focus Visible (Level AA): Any user interface component that has keyboard focus can be made visually obvious.
This means that whenever an interactive element (like a link, button, form field, or custom widget) receives keyboard focus, there must be a distinct visual change that clearly differentiates it from other elements and from its non-focused state. The change must be sufficient for a user to readily perceive it.
Requirements
Practical Guidelines for Compliance
Achieving compliance with WCAG 2.4.7 is primarily a design and CSS implementation task, though JavaScript may be involved for custom components.
Do Not Remove Default Focus Styles Blindly
Browsers provide default focus indicators (often an outline). Many developers remove these for aesthetic reasons using outline: none; or border: 0; without providing a suitable alternative. This is one of the most common WCAG failures for 2.4.7.
Implement Custom Focus Styles (If Necessary)
If default outlines are removed, or if a more branded or prominent focus style is desired, ensure a custom style is applied using CSS pseudo-class :focus (or :focus-visible for more nuanced control).
Effective Focus Indicator Properties:
Key Considerations for Custom Styles:
Using :focus-visible (Recommended for Modern Browsers)
The CSS pseudo-class :focus-visible allows browsers to apply a focus indicator only when it makes sense. Typically, this means applying the focus indicator when using keyboard navigation, but not when clicking with a mouse (as a mouse user already knows where they clicked). This provides a better experience for mouse users without sacrificing keyboard accessibility.
Examples of Correct and Incorrect Implementations
Correct Implementations
These examples demonstrate how to provide clear and visible focus indicators.
HTML Structure:
CSS for a prominent outline:
CSS for a combined focus style (border + background):
Incorrect Implementations
These examples show common mistakes that lead to non-compliance.
HTML Structure (same as above):
CSS that removes focus without replacement:
CSS where focus is hidden:
Best Practices and Common Pitfalls
Best Practices
Common Pitfalls
Conclusion
WCAG 2.4.7 Focus Visible is a critical component of web accessibility, ensuring that all users, especially those relying on keyboard navigation, can effectively interact with digital content. By providing clear, visible, and consistent focus indicators, you create a more usable, understandable, and equitable web experience for everyone. Always remember to test your interfaces thoroughly using only a keyboard to catch any focus-related issues.
Related posts
- WCAG 5.2.3: Complete processes
- WCAG 5.2.4: Only Accessibility-Supported Ways of Using Technologies
- WCAG 5.2.5: Non-Interference
- WCAG 5.3.1: Required elements of the conformity declaration
- WCAG 5.3.2: Optional Components of a Conformance Claim
Still looking for answers?
Ask our experts using online chat