chiprook
← Software
SoftwareOctober 25, 2026, 15:30

CSS contrast-color() picks white or black text for any background

The contrast-color() function in CSS Color Level 5 takes a background color and returns white or black, whichever has higher contrast. It has shipped in Chrome 147, Firefox 146 and Safari 26 since April 2026. On mid-tone backgrounds the best result bottoms out near 4.58:1.

CSS contrast-color() picks white or black text for any background
#Chrome#Firefox#Safari#CSS
Read next
Software

CSS gains progress(), alpha() and revert-rule across all engines

Software

CSS gains shape(), border-shape and corner-shape to break the web out of boxes

Software

JavaScript's Math.sumPrecise() eliminates floating-point summation errors

Software

Out-of-order HTML streaming moves from JS frameworks into browsers