Accessibility
a11y/focus-not-obscured
Sticky headers, footers, cookie banners and chat widgets never fully cover the element that has keyboard focus.
seriousmanualWCAG 2.4.11 · AAfe-a11y-keyboard
Why
When the browser scrolls a focused link under a sticky header or a cookie bar, a keyboard user cannot see where they are. This is new in WCAG 2.2 and no automated engine checks it.
Fix
Set scroll-padding-top (and scroll-padding-bottom for a sticky footer) on the scroll container (html) to the height of the sticky bars, ideally from the same custom property. Let banners be dismissed, and do not cover content with a non-modal overlay that stays open while the user tabs.
Examples
/* bad: a 64px sticky header and nothing else */
.site-header { position: sticky; top: 0; height: 4rem; }
/* good */
:root { --header-h: 4rem; }
html { scroll-padding-top: calc(var(--header-h) + 0.5rem); }
.site-header { position: sticky; top: 0; height: var(--header-h); }Sources
Facts
- Id
a11y/focus-not-obscured- Severity
- serious
- Check
- manual a person reviews it; the report lists it as a checklist
- Applies to
cssscsslesspage- WCAG 2.2
- 2.4.11, level AA
- Taught by the skill
fe-a11y-keyboardKeyboard access and focus- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain a11y/focus-not-obscured