The CSS contrast-color() function isn't widely supported yet, but you can approximate it today using OKLCH color space and relative color syntax. By checking if a color's lightness is above or below 0.72, you can determine whether black or white text will contrast better: `color: oklch(from <your color> round(1.21 - L) 0 0);`.

7m read timeFrom css-tricks.com
Post cover image
Table of contents
WCAG 2.2New ApproachLCH vs. OKLCHOne Step FurtherConclusion
1 Comment

Sort: