← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Colour Contrast

accessibility CSS3 Beginner

Also Known As

contrast ratio WCAG contrast colour accessibility

TL;DR

The ratio between foreground and background colours — WCAG requires 4.5:1 for normal text and 3:1 for large text at AA level, ensuring readability for low-vision users.

Explanation

Contrast ratio is calculated from relative luminance: 1:1 (identical) to 21:1 (black on white). WCAG AA requires: 4.5:1 for text under 18pt (or 14pt bold), 3:1 for large text (18pt+ or 14pt+ bold), 3:1 for UI components and graphical objects. WCAG AAA requires 7:1 for normal text. Grey text on white, light text on coloured backgrounds, and disabled-looking active elements are common failures. Tools: Colour Contrast Analyser, browser DevTools accessibility panel.

Diagram

flowchart TD
    subgraph WCAG_Requirements
        AA_NORMAL[AA Normal text<br/>minimum 4.5:1 ratio]
        AA_LARGE[AA Large text 18pt+<br/>minimum 3:1 ratio]
        AAA_NORMAL[AAA Normal text<br/>minimum 7:1 ratio]
    end
    FORE[Foreground colour] --> RATIO[Calculate contrast ratio]
    BACK[Background colour] --> RATIO
    RATIO --> CHECK{Passes?}
    CHECK -->|yes| PASS[Accessible]
    CHECK -->|no| ADJUST[Darken foreground<br/>or lighten background]
    subgraph Tools
        TOOL1[browser DevTools<br/>accessibility panel]
        TOOL2[WebAIM contrast checker]
        TOOL3[axe browser extension]
    end
style AA_NORMAL fill:#238636,color:#fff
style PASS fill:#238636,color:#fff
style ADJUST fill:#d29922,color:#fff

Common Misconception

As long as text is readable to most users, contrast is fine — 15% of men have some form of colour vision deficiency; what appears high contrast to some fails completely for others.

Why It Matters

Low contrast text is unreadable for low-vision users, users in bright sunlight, and the ~10% of the population with colour vision deficiency — it is also a common WCAG audit failure.

Common Mistakes

  • Grey text that looks 'modern' but fails contrast — #999999 on white is 2.85:1, failing WCAG AA.
  • Placeholder text as the only hint — placeholder disappears on input and typically has low contrast.
  • Colour alone to convey meaning — red/green distinction fails for colour-blind users; add icons or text.
  • Not testing interactive states — focus, hover, and active states must also meet contrast requirements.

Code Examples

✗ Vulnerable
/* Common contrast failures:
.text-muted { color: #999; }         /* 2.85:1 on white — FAIL */
.subtitle   { color: #aaa; }         /* 2.32:1 on white — FAIL */
.error      { color: #f00; }         /* 3.99:1 on white — FAIL for normal text */
.link       { color: #6699cc; }      /* 3.04:1 on white — FAIL */
✓ Fixed
/* WCAG AA passing contrast ratios on white (#fff):
.text-muted { color: #767676; }      /* 4.54:1 — PASS AA */
.subtitle   { color: #595959; }      /* 7.0:1 — PASS AAA */
.error      { color: #d93025; }      /* 4.75:1 — PASS AA */
.link       { color: #0066cc; }      /* 4.51:1 — PASS AA */
/* Test at: https://webaim.org/resources/contrastchecker/ */

Added 15 Mar 2026
Edited 22 Mar 2026
Views 30
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 2 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T
No pings yesterday
Amazonbot 9 Perplexity 9 Unknown AI 3 Ahrefs 2 Google 2 SEMrush 1
crawler 24 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Low
⚡ Quick Fix
Check contrast ratio with the browser DevTools Accessibility panel or Colour Contrast Analyser — body text needs 4.5:1 minimum, large text (18pt+ or 14pt bold) needs 3:1
📦 Applies To
css CSS3 web
🔗 Prerequisites
🔍 Detection Hints
Light grey text on white background; placeholder text below 3:1; disabled element text below 3:1 (exempt but consider UX)
Auto-detectable: ✓ Yes axe lighthouse colour-contrast-analyser whocanuse.com
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✗ Manual fix Fix: Low Context: File

✓ schema.org compliant