Dostępność
a11y/font-size-relative
The root font size is not set in pixels, so text follows the reader's default size; use rem for type.
drobnastatyczneWCAG 1.4.4 · AAfe-a11y-visual
Dlaczego
A pixel size on html overrides the default text size a reader chose in the browser settings. Page zoom still works, so this is not a WCAG failure on its own, but people who only raise the default size get no larger text.
Poprawka
Leave the root size alone, or set it as a percentage (100%), and size type in rem. If the design system needs 10px maths, use 62.5% on the root and keep every other size in rem.
Przykłady
/* bad */
html { font-size: 16px; }
/* good */
html { font-size: 100%; }
h1 { font-size: 2.5rem; }Źródła
Fakty
- Identyfikator
a11y/font-size-relative- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
cssscsslesshtmlvuesvelteastro- WCAG 2.2
- 1.4.4, poziom AA
- Uczy jej skill
fe-a11y-visualContrast, colour, size and reflow- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/font-size-relative