Search pages
Search all CSS Showcase pages by name
Modern CSS Colour Spaces
Step into the future of colour with perceptually uniform colour spaces like oklch, display-p3 wide gamut, and powerful colour manipulation functions.
What Are Modern Colour Spaces?
Traditional CSS colours (hex, rgb, hsl) are limited to the sRGB colour space, which represents only about 35% of colours the human eye can see. Modern CSS introduces new colour spaces that unlock a wider range of more vibrant colours and provide perceptually uniform colour manipulation.
Limited gamut
rgb(255, 0, 128)Wide gamut — more vibrant!
color(display-p3 1 0 0.5)- →
oklch()— Perceptually uniform, human-friendly colour space - →
display-p3— Wide gamut colour space (50% more colours than sRGB) - →
color-mix()— Mix any two colours in any colour space - →
Relative colours— Modify existing colours dynamically
OKLCH: Perceptually Uniform Colours
OKLCH (Oklab Lightness Chroma Hue) is a perceptually uniform colour space. The same numeric change in colour values produces the same perceived change in colour by humans, regardless of where you are in the colour space.
oklch(0.5 0.2 0)Pinkoklch(0.5 0.2 60)Orangeoklch(0.5 0.2 120)Yellowoklch(0.5 0.2 180)Greenoklch(0.5 0.2 240)Cyanoklch(0.5 0.2 300)BlueLightness0 – 10 = black, 1 = white. Controls perceived brightness independently from hue.
Chroma0 – 0.40 = grey, 0.4 = maximum vibrancy. Controls colour saturation.
Hue0 – 360°0 = pink, 120 = green, 240 = blue. Rotates around the colour wheel.
Display P3: Wide Gamut Colours
Display P3 is a wide gamut colour space that can represent 50% more colours than sRGB. It's supported on modern displays (iPhones since 2017, MacBooks since 2016, many modern monitors). These colours are noticeably more vibrant and saturated.
rgb(255, 0, 0)color(display-p3 1 0 0)rgb(0, 255, 0)color(display-p3 0 1 0)rgb(0, 0, 255)color(display-p3 0 0 1)Note: You'll only see the difference on a wide gamut display (modern phones, tablets, and monitors).
color-mix(): Blend Any Two Colours
The color-mix() function lets you blend any two colours in any colour space. This is incredibly powerful for creating tints, shades, and variations of colours without complex calculations.
#2563eb#ffffffcolor-mix(in oklch, #2563eb 70%, white)#ef4444#3b82f6color-mix(in oklch, #ef4444, #3b82f6)#10b981#000000color-mix(in oklch, #10b981 60%, black)Relative Colours: Dynamic Colour Manipulation
Relative colour syntax lets you create new colours based on existing ones by modifying specific channels. This is perfect for creating hover states, active states, and colour variations dynamically.
#2563eboklch(from #2563eb calc(l + 0.2) c h)#10b981oklch(from #10b981 0.4 c h)#ef4444oklch(from #ef4444 l calc(c * 1.5) h)Real-World Applications
Let's see how these modern colour spaces solve real design problems. A single base colour can generate an entire theme using relative colours and color-mix().
Blue Theme
Green Theme
Amber Theme
Browser Support
Modern colour spaces have excellent browser support, with all major browsers supporting oklch, color-mix(), and display-p3 since 2023.
Widely Supported
- OKLCH: Chrome 111+, Safari 15.4+, Firefox 113+
- color-mix(): Chrome 111+, Safari 16.2+, Firefox 113+
- Relative colours: Chrome 119+, Safari 16.4+, Firefox 120+
- Display P3: Chrome 111+, Safari 10+, Firefox 113+
Best practice: Always provide an sRGB fallback before your modern colour value. Browsers that don't understand the new syntax will simply ignore it and use the fallback.
Keep Learning
Explore related features that pair brilliantly with modern colour spaces.