Technique G195:Using an author-supplied, visible focus indicator
About this Technique
This technique relates to:
- 1.4.11: Non-text Contrast (Sufficient)
- 2.4.7: Focus Visible (Sufficient)
- 2.4.13: Focus Appearance (Sufficient)
This technique applies to all technologies.
Description
The objective of this technique is enhance the focus indicator in the browser, by creating a visible one in the content. The default focus indicator in some browsers is a thin, dotted, black line. It can be difficult to see the line when it is around a form element which already has an outline, when the focused element is inside a table cell, when the focused element is very small, or when the background of the page is a dark color. Some browsers use a pale blue outline, which can be difficult to see on some backgrounds.
In this technique, when the user places focus on an element using the keyboard, the application makes that focus more visible, using a combination of a highly contrasting color, a thick line, and other visual indicators such as a glow.
Examples
Example 1: Links
A Web page has a dark background color and light text and links. When focus lands on a link, the link is outlined with a bright yellow line, 3 pixels wide.
Example 2: Form Elements
A Web page includes a form inside a table. The borders of both the table and the form elements are thin, black lines. When focus lands on a form element, the element is outlined with a 5 pixel red line that is partially transparent. The red is equivalent to a hex color of #FF3838, providing a 3.6:1 contrast ratio with the white background.
Tests
Procedure
For each user interface component on the page that should receive keyboard focus:
- Navigate to the component and check that it has a visible focus indicator.
- Check that the focus indicator area is at least the size of a 1 CSS px border around the component.
- If the focus indicator area is not at least equal to the area of a 1 CSS pixel border, check that it has an area of at least 4 CSS pixels along the shortest side of the component.
- Check that the change of contrast of the indicator between focused and unfocused states has a ratio of 3:1 or more for the minimum focus indicator area.
- If the focus indicator does not have 3:1 contrast ratio with its adjacent colors, check that it is at least 2px thick.
Expected Results
- Checks #2, #4, and #5 are true.