Dostępność
a11y/focus-not-obscured
Sticky headers, footers, cookie banners and chat widgets never fully cover the element that has keyboard focus.
poważnaręczneWCAG 2.4.11 · AAfe-a11y-keyboard
Dlaczego
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.
Poprawka
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.
Przykłady
/* 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); }Źródła
Fakty
- Identyfikator
a11y/focus-not-obscured- Waga
- poważna
- Sprawdzanie
- ręczne ocenia człowiek; raport podaje to jako listę kontrolną
- Dotyczy plików
cssscsslesspage- WCAG 2.2
- 2.4.11, poziom AA
- Uczy jej skill
fe-a11y-keyboardKeyboard access and focus- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/focus-not-obscured