What Is Luminance?
Luminance measures the perceived brightness of a color as perceived by the human eye. In web design and CSS, relative luminance is calculated using a specific formula that accounts for how human vision perceives different wavelengths of light differently than a camera or raw sensor would.
Relative Luminance in CSS
Relative luminance is defined mathematically for each color channel using the sRGB color space. The formula accounts for the non-linear response of human vision to light intensity:
For each RGB component:
- If value ≤ 0.03928: component = value / 12.92
- Otherwise: component = ((value + 0.055) / 1.055) ^ 2.4
Relative Luminance = 0.2126 × R + 0.7152 × G + 0.0722 × B
Luminance Measurement Units
The candela per square meter (cd/m²) is the standard unit for measuring luminance on displays. This unit represents the intensity of light emitted from a surface:
- SDR reference white: Approximately 80 cd/m²
- HDR reference white: Defined as 203 cd/m²
- HDR peak white: Can reach up to 10,000 cd/m² on capable displays
Understanding these concepts is essential for implementing modern color features like those covered in our CSS Color Module Level 4 guide. For comprehensive web accessibility implementation, our web development services team can help ensure your color systems meet all WCAG requirements.
21:1
Maximum Contrast Ratio
4.5:1
WCAG AA Normal Text
3:1
WCAG UI Components
10,000
HDR Peak cd/m²
Color Contrast: The Mathematics of Visual Distinction
Color contrast measures the difference in luminance between two adjacent colors, typically text and its background. This difference directly impacts readability and accessibility. Proper color contrast is a fundamental aspect of web accessibility that ensures all users can effectively engage with your content.
The Contrast Ratio Formula
The Web Content Accessibility Guidelines (WCAG) define contrast ratio using relative luminance:
Contrast Ratio = (L1 + 0.05) / (L2 + 0.05)
Where:
- L1 = relative luminance of the lighter color
- L2 = relative luminance of the darker color
- L1 must be greater than or equal to L2
WCAG Contrast Requirements
| Requirement Level | Normal Text | Large Text | UI Components |
|---|---|---|---|
| Level AA | 4.5:1 | 3:1 | 3:1 |
| Level AAA | 7:1 | 4.5:1 | Not specified |
Practical Contrast Examples
- White on Black: 21:1 (maximum possible)
- Dark gray (#333) on White: 12.6:1 (passes all levels)
- Medium gray (#767) on White: 4.5:1 (passes AA normal)
- Light gray (#999) on White: 2.8:1 (fails all requirements)
For a deeper dive into color spaces and gamut, see our guide on Color Gamut and Wide Color. Implementing proper contrast ratios improves both accessibility and SEO, as search engines favor user-friendly designs.
Dynamic Range: From SDR to HDR
Dynamic range represents the ratio between the brightest and darkest colors a display can render. Understanding dynamic range helps create content that looks excellent across different display capabilities.
Standard Dynamic Range (SDR)
Traditional displays operate in SDR with approximately 8.6 stops of dynamic range:
- White luminance: ~80 cd/m²
- Black luminance: ~0.2 cd/m²
- HDR headroom: 0 stops
High Dynamic Range (HDR)
HDR extends beyond SDR limitations significantly:
- HDR reference white: 203 cd/m² (ITU-R BT.2100)
- Peak white luminance: Up to 10,000 cd/m²
- Dynamic range: Up to 23.3 stops
- HDR headroom: 2+ stops (varies by display)
Browser Support
Modern CSS supports HDR through new properties:
dynamic-range-limit: standard | constrained | no-limit;
color(rec2100-pq 0.58 0 0);
color(rec2100-hlg 0.58 0 0);
These HDR capabilities build upon the foundation of relative color syntax for advanced color manipulation. As HDR displays become more common, implementing these features future-proofs your web applications for the next generation of display technology.
CSS Color Levels 4 and 5 introduce powerful capabilities for color management
Wide Color Gamut
Support for Display P3 and Rec. 2020 color spaces with colors beyond traditional sRGB
color() Function
Specify colors in multiple color spaces including sRGB, Display P3, and CIELAB
Relative Color Syntax
Transform existing colors with arithmetic operations for lightening, darkening, and saturation
color-mix() Function
Blend two colors with configurable interpolation methods and color space selection
Device-Independent Colors
CIELAB, LCH, OKLAB, and OKLCH for perceptually uniform color specification
HDR Support
PQ and HLG transfer functions for high dynamic range content rendering
1:root {2 /* Text colors (7:1 minimum for AAA compliance) */3 --text-primary: #1A1A1A; /* 16.6:1 on white */4 --text-secondary: #4A4A4A; /* 7.0:1 on white */5 --text-muted: #6B6B6B; /* 4.5:1 on white - large text only */6 7 /* Background colors */8 --bg-primary: #FFFFFF;9 --bg-secondary: #F5F5F5;10 11 /* Link colors (7:1 minimum) */12 --link-primary: #0056CC; /* 7.4:1 on white */13 --link-visited: #551A8B; /* 7.6:1 on white */14 15 /* UI component colors (3:1 minimum) */16 --border-default: #9CA3AF; /* 3.0:1 on white */17 --border-focus: #2563EB; /* 4.5:1 on white */18}1/* Wide Color Gamut */2color(display-p3 1 0 0); /* More saturated red */3 4/* Relative Color Syntax */5--primary-light: color(from var(--primary) srgb 1.2 1.2 1.2);6 7/* Color Mixing */8color-mix(in oklch, crimson 60%, plum 40%);9 10/* Device-Independent Colors */11color: oklch(55% 0.15 280deg);12color: lab(50% 40 20);13 14/* HDR Colors */15color(rec2100-pq 0.58 0 0);16color(rec2100-hlg 0.58 0 0);Frequently Asked Questions
Color and Typography
Effective typography goes hand-in-hand with color selection. For guidance on pairing fonts with your color choices, see our comprehensive guide on Six Tips for Better Web Typography. Good typography practices combined with proper contrast ratios ensure your content remains readable across all devices and user preferences.
When implementing dark mode or high contrast themes, remember to test all text sizes and weights against your background colors to maintain WCAG compliance. Proper color and typography combinations also improve SEO performance as search engines prioritize accessible, well-structured content.
Summary
Understanding colors and luminance is essential for creating accessible, visually compelling web experiences:
Key Takeaways
-
Luminance is perceptual: The human eye perceives brightness differently than sensors measure it, which is why the weighted formula (0.2126 × R + 0.7152 × G + 0.0722 × B) prioritizes green perception
-
Contrast ratios matter: WCAG requirements (4.5:1 normal, 3:1 large) ensure readability for users with visual impairments
-
Dynamic range extends: HDR content can represent up to 23+ stops of dynamic range compared to SDR's ~9 stops
-
Modern CSS enables sophisticated color: Features like color(), relative color syntax, and color-mix() provide powerful tools
-
Accessibility is built-in: Designing with accessibility from the start produces better results than retrofitting
-
Testing is essential: Regular contrast checking and accessibility audits ensure ongoing compliance
Need help implementing accessible color systems in your web projects? Our web development services include comprehensive accessibility implementation and testing to ensure your applications meet all WCAG requirements and provide excellent user experiences.
Sources
-
W3C CSS Color HDR Module Level 1 - Comprehensive technical specification defining HDR color terminology and CSS properties
-
WebAIM Contrast Checker - Official contrast ratio calculator and testing tool for WCAG compliance
-
MDN Web Docs: Luminance - Reference for relative luminance calculation in CSS
-
WCAG 2.1 Contrast Requirements - Official accessibility guidelines for color contrast
-
CSS Color Module Level 4 - W3C specification for modern CSS color features