CSS :focus-visible Makes outline:none Safe for Accessibility Since 2020
Removing the default focus outline with 'outline: none' may look cleaner visually, but it fails WCAG 2.4.7 by leaving keyboard users unable to identify which element is focused. Before 2020, developers relied on JavaScript workarounds to show focus rings only for keyboard navigation, which added overhead and could produce inconsistent results. The CSS pseudo-class ':focus-visible', introduced in Chrome and Edge in October 2020, solves this natively by using the browser's own heuristic to determine whether focus was triggered by a keyboard or a pointer. By pairing 'outline: none' on ':focus' with a custom outline on ':focus-visible', developers can suppress the ring on mouse clicks while preserving it for keyboard users — no JavaScript required. Full support across all major evergreen browsers was achieved by 2022, making the old JavaScript-based approach largely unnecessary.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in