Focus Visible and Focus Not Obscured: How to Pass WCAG 2.4.7 and 2.4.11

To pass WCAG 2.4.7 Focus Visible, every element a keyboard user can reach needs a visible focus indicator. To pass 2.4.11 Focus Not Obscured (Minimum), a focused element must not be completely hidden behind something the page adds, such as a sticky header or a cookie banner. In CSS, that means keeping a clear :focus-visible outline and adding scroll-padding so focused items scroll clear of fixed bars.

What do 2.4.7 and 2.4.11 require?

CriterionLevelRequirement
2.4.7 Focus VisibleAAAny keyboard-operable interface has a mode of operation where the keyboard focus indicator is visible
2.4.11 Focus Not Obscured (Minimum)AA, new in WCAG 2.2When a component receives keyboard focus, it is not entirely hidden by author-created content
2.4.12 Focus Not Obscured (Enhanced)AAANo part of the focused component is hidden
2.4.13 Focus AppearanceAAAThe focus indicator meets minimum size and contrast

At Level AA, 2.4.7 does not set a size or color. It requires that focus can be seen. In practice, a thin, faint outline is hard to see, and a focus indicator that is a meaningful part of the interface should also meet 3:1 contrast under 1.4.11 Non-text Contrast. See the WCAG 2.2 AA checklist and what is new in WCAG 2.2.

What is the most common way to fail 2.4.7?

Removing the outline:

/* Bad: removes the focus indicator for everyone */
button:focus,
a:focus {
  outline: none;
}

Designers often do this because the default ring looks unrefined. If you remove it, you must replace it with something visible.

How do you style a good focus indicator?

Use :focus-visible, which shows the indicator for keyboard users and usually not for mouse clicks.

:focus-visible {
  outline: 3px solid #0b5fff;
  outline-offset: 2px;
}

What if the background changes?

An outline that works on white may vanish on a dark section. Use a two-color indicator so one part is always visible:

:focus-visible {
  outline: 3px solid #ffffff;
  box-shadow: 0 0 0 6px #1a1a1a;
}

Test it on light, dark and image backgrounds.

What about Windows high contrast mode?

Browsers draw their own colors in forced-colors modes and can ignore box shadows. Outlines are kept, so prefer an outline for the main indicator. If you hide an outline in normal mode, keep a transparent one so high contrast mode can still show it:

.btn:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px #0b5fff;
}

Is :focus-visible enough, or should you use :focus?

:focus-visible is the right default. Keep a fallback only if you must support very old browsers:

:focus {
  outline: 3px solid #0b5fff;
}
:focus:not(:focus-visible) {
  outline: none;
}

Do not use the second rule in browsers that do not support :focus-visible, because it can remove focus for keyboard users as well.

How do sticky headers fail 2.4.11?

A fixed header or footer sits above the page content. When a keyboard user tabs down a long page, the browser scrolls the focused element into view, and it can land beneath the header. If it is completely covered, that fails 2.4.11.

The same happens with cookie banners, chat buttons, promo bars and bottom navigation on mobile.

How do you fix a sticky header?

Tell the browser to leave space when it scrolls to a focused element. Add scroll-padding to the scrolling container, usually html:

html {
  scroll-padding-top: 5rem;     /* height of the sticky header */
  scroll-padding-bottom: 4rem;  /* height of a sticky footer or banner */
}

For a specific element, scroll-margin works too:

.form-field {
  scroll-margin-top: 6rem;
}

Match the values to the real heights, and update them if the header changes size on mobile.

body {
  padding-bottom: 5rem; /* space for a fixed banner */
}

Does partial overlap pass?

At Level AA, yes. 2.4.11 fails only if the focused item is entirely hidden. A partly visible item passes, though users will find it hard to use. The AAA criterion 2.4.12 asks that no part is hidden. Aim for the stronger result where you can, because users need to see the whole control.

What about dialogs and overlays that open on purpose?

Content that a user opens deliberately, such as a modal dialog, may cover the rest of the page, because the page behind it is not meant to be used while the dialog is open. Keep focus inside the dialog, and make sure the focused element inside it is visible. See the accessible modals guide for patterns.

How do you test focus visibility?

  1. Press Tab through the whole page and look for any item where you cannot see focus (2.4.7).
  2. Tab through long pages and forms with a sticky header and footer. Is any focused item completely hidden (2.4.11)?
  3. Repeat at 200% and 400% zoom and on a phone.
  4. Test with a cookie banner and a chat widget visible.
  5. Test on dark and image sections.
  6. Check the focus indicator contrast with a color checker. See color contrast checkers.

For the full process, see the keyboard accessibility testing checklist.

Kerbwise audits the page you have open against WCAG 2.2 Level A and AA and ranks accessibility issues by severity, with the WCAG number, who is affected and how to fix each one. Focus problems depend on how the page behaves as you tab, so confirm them with a keyboard test.

Try Kerbwise on a page you own

Try Kerbwise ($29 one-time) to run this audit locally and export a client-ready PDF report. Get it on the Chrome Web Store or read more on the Kerbwise page.

Frequently asked questions

What is WCAG 2.4.7 Focus Visible?

It requires that any interface a user can operate with a keyboard has a visible keyboard focus indicator. It is a Level AA criterion.

What is WCAG 2.4.11 Focus Not Obscured (Minimum)?

It is a Level AA criterion added in WCAG 2.2. A focused component must not be entirely hidden by content the page adds, such as a sticky header or cookie banner.

Is it okay to use outline: none?

Only if you replace the outline with another clearly visible focus style. Removing it with no replacement fails 2.4.7.

How do I stop a sticky header from covering focused elements?

Add scroll-padding-top to the html element, equal to the header height, and add scroll-padding-bottom for fixed footers.

How can I tell if my focus indicator has enough contrast?

Measure its color against the adjacent background, and aim for at least 3:1. A two-color indicator keeps it visible on light and dark backgrounds.

Get Kerbwise for Chrome | Kerbwise | Yuktix Labs home