Skip to content

Focus Not Obscured ​

PropertyValue
IDfocus-not-obscured
SeverityError
WCAG2.4.11 Focus Not Obscured
ConfigfocusNotObscured

What it checks ​

Detects when a focused element is not visible because other content covers it. The verdict follows WCAG 2.4.11 (AA): an element is obscured only when it is entirely hidden, so a cover that leaves part of it visible passes.

How it works ​

For each focused element during the tab crawl, the crawler:

  1. Samples five points (centre and four inner corners) with document.elementsFromPoint(), with pointer-events forced on so non-interactive overlays are seen too.
  2. Applies a style check: anything stacked above the element that paints (background, image, border, shadow, text, or a painting ::before/::after on an ancestor) counts as a cover. Transparent, opacity below 0.1 and visibility:hidden covers do not.
  3. Elements with anything stacked above them are then re-focused and pixel-probed: the element's padded region is screenshotted as-is and again with the element set to visibility:hidden. Identical renderings mean the element contributes no visible pixels, so it is covered, whatever the mechanism.

The pixel probe overrides the style check when it can decide. When it cannot (the element paints nothing of its own, a capture fails, or focus will not stay on the element) the style result stands. Elements with nothing stacked above them are not probed.

Examples ​

Fail ​

html
<!-- Sticky header covers focused elements when scrolled -->
<header
  style="position: fixed; top: 0; width: 100%; height: 60px; z-index: 100;"
>
  Navigation
</header>
<main>
  <!-- This link might be hidden behind the header when focused -->
  <a href="/about">About</a>
</main>

Pass ​

html
<!-- Header scrolls with content, doesn't obscure -->
<header>Navigation</header>
<main>
  <a href="/about">About</a>
</main>

How to fix ​

  • Use scroll-padding-top to account for fixed headers when elements are scrolled into view
  • Ensure cookie banners and overlays don't cover focusable content
  • Use scroll-margin on focusable elements to provide clearance from sticky elements
  • Consider dismissing non-essential overlays when the user starts keyboard navigation

Keylens auto-dismisses known cookie/consent banners before the crawl (see Configuration: prepare phase), so this rule normally evaluates the page in its post-consent state rather than flagging the banner itself. To audit a banner deliberately — e.g. to verify it doesn't obscure focus while open — run with --keep-overlays (prepare.dismissOverlays: false).

Released under the Apache License 2.0.