--- url: "https://www.w3.org/WAI/WCAG22/Techniques/css/C41" titulek: "C41: Creating a strong focus indicator within the component | WAI | W3C" h1: "Technique C41:Creating a strong focus indicator within the component" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 05:34:15" znaku: 2124 slov: 300 kodovani: "utf-8" sha256: "8b1997a055b265e67e763384ff3a435db296a9003b693378aab93d4ba911da0f" --- # Technique C41:Creating a strong focus indicator within the component ## About this Technique This technique relates to [2.4.13 Focus Appearance](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance) (**Sufficient**). This technique applies to 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 create a highly visible focus indicator that has sufficient contrast against the internal background color of a component. ## Examples The examples demonstrate a simple implementation where a focus styles is applied to blue background. As the indicator is contained inside the component, you can be sure it maintains contrast whatever background the component is placed on ### Example 1: Inner border #### HTML ``` ``` #### CSS CSS to provide the indicator. It narrows the scope to buttons within the `main` element. ``` button { background-color: #003366; color: white; padding: 10px; } main button:focus { outline: 3px #ffff00 solid; outline-offset: -4px; } ``` Figure 1. The default and focused states of the button. ## Related Resources *No endorsement implied.* - [The :focus pseudo-class on the Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus) - [The :focus-visible pseudo-class on the Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) ## Tests ### Procedure For each focusable user interface component: 1. Place keyboard focus on each focusable user interface element on the page using the keyboard. 2. Check that the focus indicator area is at least the size of a 2 CSS px border around the component. 3. Check that the change of contrast of the indicator between focused and unfocused states has a ratio of at least 3:1 for the minimum focus indicator area. ### Expected Results - #2 and #3 are true. Back to Top