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);`.

1 Comment
Sort: