--- url: "https://www.w3.org/WAI/WCAG22/Techniques/css/C45" titulek: "C45: Using CSS :focus-visible to provide keyboard focus indication | WAI | W3C" h1: "Technique C45:Using CSS :focus-visible to provide keyboard focus indication" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 05:34:00" znaku: 3636 slov: 529 kodovani: "utf-8" sha256: "e5dc90be387453ca16e0d2ab75d067c51003be4abb511332090f39e105cf60b4" --- # Technique C45:Using CSS `:focus-visible` to provide keyboard focus indication ## About this Technique This technique relates to [2.4.7 Focus Visible](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible) (**Sufficient**). This technique applies to all technologies that support CSS. Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The objective of this technique is to provide custom styles for interactive elements when they receive keyboard focus. In this example, this is achieved using the CSS `:focus-visible` pseudo-class. Styles defined with the regular `:focus` pseudo-class are applied whenever an element has focus, regardless of how it received focus. In contrast, user agents apply additional heuristics and logic to decide when to show `:focus-visible` styles – in particular, browsers always show these styles when a user is navigating using the keyboard, but will generally *not* show them as a result of a mouse/pointer interaction (with the exception of elements that also support keyboard input, such as `` elements). This allows authors to provide strong visible focus indication for keyboard users, without forcing them on mouse/pointer users who may not necessarily want or need them (for instance, because they find them visually distracting). This satisfies the requirement of providing a mode of operation where the keyboard focus indicator is visible. Note This technique is only sufficient *if* it uses styles that provide a *visible* focus indicator. Note There may be situations where mouse/pointer users could also benefit from having a visible focus indicator, even though they did not set focus to an element using the keyboard. As a best practice, consider still providing an explicit `:focus` style for these cases. ## Examples ### Example 1: Using CSS `:focus-visible` to provide keyboard focus indication In this example, we have a standard ` … ``` ## Related Resources *No endorsement implied.* 1. [CSS Selectors Level 4 - `:focus-visible` pseudo-class](https://www.w3.org/TR/selectors-4/#the-focus-visible-pseudo) . 2. [MDN - `:focus-visible` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) . ## Tests ### Procedure For each user interface component that can receive keyboard focus: 1. Set focus to the interface component using the keyboard (generally, navigating to the component using Tab / Shift+Tab ) 2. Verify that once the component has received focus, a focus indicator is visible ### Expected Results - Check #2 is true. Back to Top