Module lessons (1/4)
Modern Colors (hsl, oklch) & WCAG Contrast
Understand hex, rgb, hsl, and uniform oklch() color channels alongside WCAG 4.5:1 text contrast checks.
What you'll learn in this lesson
- Compare classic
hex,rgb(),hsl(), and modern perceptually uniformoklch()color formats. - Add clean alpha transparency (
oklch(0.6 0.18 250 / 0.15)orrgb(... / 0.8)). - Enforce WCAG 2.1 contrast ratios (4.5:1 for body copy, 3.0:1 for large text/icons) automatically.
Overview
For years developers picked colors in Hex (#0284c7) or HSL (hsl(200, 98%, 39%))—only to notice a trap in HSL: hsl(60, 100%, 50%) (yellow) is blindingly bright white-contrast failing, while hsl(240, 100%, 50%) (blue) looks super dark, even though both claim 50% lightness!
Modern oklch(L C H) solves this cleanly using human vision math:
Sections covered in this lesson
- 1From Hex Codes to Perceptual
oklch() - 2Test Colors Against WCAG AA & AAA Live
Unlock "Modern Colors (hsl, oklch) & WCAG Contrast" and the full Modern HTML & CSS curriculum
Understand hex, rgb, hsl, and uniform oklch() color channels alongside WCAG 4.5:1 text contrast checks.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.