Dostępność
a11y/color-contrast
Text has a contrast ratio of at least 4.5:1 with its background; large text (24px, or 18.5px bold) at least 3:1.
poważnaw przeglądarceWCAG 1.4.3 · AAfe-a11y-visual
Dlaczego
Low-contrast text is hard or impossible to read for people with low vision, colour vision deficiency, ageing eyes, or anyone on a phone in sunlight. Grey placeholder-style text and brand colours on white are the usual failures.
Poprawka
Pick text and background tokens as tested pairs: 4.5:1 for body text, 3:1 for text of at least 24 CSS px or 18.5 CSS px bold. The thresholds are hard: 4.49:1 fails. Check every state (hover, disabled is exempt, placeholder is not) and both colour schemes. Text over images needs a solid or gradient scrim behind it.
Przykłady
/* bad: #9ca3af on white is about 2.5:1 */
.muted { color: #9ca3af; }
/* good: #4b5563 on white is about 7.6:1 */
.muted { color: #4b5563; }Źródła
Fakty
- Identyfikator
a11y/color-contrast- Waga
- poważna
- Sprawdzanie
- w przeglądarce wymaga wyrenderowanej strony:
audit --url - Dotyczy plików
page- WCAG 2.2
- 1.4.3, poziom AA
- Ten sam problem w
- axe-core
color-contrast, Lighthousecolor-contrast - 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/color-contrast