Focus indicator

A focus indicator is the visible mark, usually an outline or ring, that shows which element on a web page has keyboard focus: the link, button or field that responds when a key is pressed. Browsers draw one by default. WCAG 2.2 requires a visible indicator under 2.4.7 Focus Visible, Level AA, and sets its size and contrast at Level AAA.

The longer version

Every sighted person who moves through a page from the keyboard depends on it, whether they press Tab by preference, because a mouse is hard to use, or through a switch device, since without it the keyboard still works and nobody can see where it is. WCAG 2.2, the W3C Recommendation of 12 December 2024, has four criteria about it. 2.4.7 Focus Visible, Level AA, says any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible. 2.4.11 Focus Not Obscured (Minimum), Level AA, says that when a component receives keyboard focus, it is not entirely hidden due to author-created content, such as a sticky header or a cookie banner. 2.4.12 Focus Not Obscured (Enhanced), Level AAA, asks that no part of it is hidden. 2.4.13 Focus Appearance, Level AAA, asks that an area of the indicator is at least as large as a 2 CSS pixel thick perimeter of the unfocused component and has a contrast ratio of at least 3:1 between the same pixels in the focused and unfocused states. At Level AA the contrast of the indicator falls under 1.4.11 Non-text Contrast, which asks for 3:1 against adjacent colours for the visual information needed to identify a component's state.

In CSS the indicator is drawn on the :focus or :focus-visible pseudo-class. MDN's reference explains the difference: :focus always matches the focused element, while :focus-visible matches it only when the browser's heuristics decide the focus should be made evident, so a button clicked with a mouse usually shows no ring while a text field still does, and a keyboard user always gets one. MDN lists :focus-visible as available across browsers since March 2022. That pseudo-class answers the complaint that led to the commonest focus defect there is, a rule such as *:focus { outline: none; } added because a ring appeared on every mouse click, which removes the indicator for keyboard users too. The usual fix keeps the outline and moves it to :focus-visible. Two refinements matter. An indicator drawn only with box-shadow disappears in forced colours modes, which reset box-shadow, so TetraLogical's guidance adds an outline inside a forced-colors media query. And W3C Technique C40 describes a two-colour indicator, an inner and an outer band at least 2 CSS pixels thick whose colours have a contrast ratio of at least 9:1 with each other, so that one of them reaches 3:1 against any solid background.

In design QA the failures repeat. The outline was reset and nothing replaced it. The indicator is a thin line in a brand colour that nearly matches the background. A parent with overflow hidden clips the ring to nothing on cards and carousels. The ring is drawn on a wrapper while focus sits on an invisible element inside it. A sticky header covers the focused field when the page scrolls to it, which fails 2.4.11. Or the design file never drew a focus state, so the build shows the browser default on some components and none on others. Most of these pass an automated scan, because a scanner cannot tell whether a person can see the change, which is why the check is done by eye.

The check takes a keyboard and a few minutes. Put the mouse aside and press Tab through the page, including every menu, dialog and form, and at each stop ask whether you can see where focus is without searching for it. On a Mac, Safari only stops on links once Press Tab to highlight each item on a webpage is ticked in Safari Settings under Advanced, so set that first. A finding names the element, the page and the browser, says whether the indicator is missing, hidden or too faint, and cites the criterion: 2.4.7 for missing, 2.4.11 for hidden, 1.4.11 at Level AA or 2.4.13 at AAA for too faint. A screenshot taken while the element has focus, or a short recording of the Tab sequence, shows the problem better than a sentence. The accessibility checklist in the Notarus templates carries 2.4.7 and 2.4.11 in its Keyboard and focus group.

Common questions

What does focus indicator mean?

A focus indicator is the visual cue that marks the element currently receiving keyboard input, usually an outline, ring or change of colour around a link, button or field. Moving with Tab moves the indicator from element to element. Without one, a keyboard user can still operate the page but cannot see where they are.

What is focus visible?

Focus Visible is WCAG 2.2 Success Criterion 2.4.7, Level AA: any keyboard operable interface has a mode of operation where the keyboard focus indicator is visible. :focus-visible is also a CSS pseudo-class that matches the focused element only when the browser decides focus should be shown, which is how a site keeps the ring for keyboard users without showing it on every mouse click.

What is focus in CSS?

:focus is a CSS pseudo-class that matches the element that currently has focus, whether it got there by keyboard, mouse, touch or script. Styles written on it, such as an outline, appear every time the element is focused. :focus-visible is the narrower pseudo-class that applies only when the browser judges the focus should be evident.

What is the difference between hover and focus?

Hover is where the mouse pointer is resting, and focus is the element that will receive keyboard input. A page can have something hovered and something else focused at the same moment. Keyboard and screen reader users never hover, so a style that appears only on :hover tells them nothing, and focus needs a style of its own.

What is focus order in accessibility?

Focus order is the sequence in which Tab moves through the interactive elements of a page. WCAG 2.2 Success Criterion 2.4.3 Focus Order, Level A, asks that where the order affects meaning or operation, components receive focus in an order that preserves meaning and operability. The focus indicator is what lets a tester see that order.

Is outline: none bad for accessibility?

Removing the outline is harmful only when nothing replaces it, which is what usually happens. A rule such as *:focus { outline: none; } hides focus for every keyboard user and fails 2.4.7 Focus Visible. Styling the indicator on :focus-visible keeps it for keyboard users and leaves mouse clicks without a ring, which is the effect the removal was trying to get.

How much contrast does a focus indicator need?

At Level AA, WCAG 2.2 Success Criterion 1.4.11 Non-text Contrast asks for a contrast ratio of at least 3:1 against adjacent colours for the visual information that identifies a component's state, focus included. At Level AAA, 2.4.13 Focus Appearance adds a size, at least a 2 CSS pixel perimeter, and 3:1 between the focused and unfocused states.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">