1 / 1
Readable Labels with contrast-color()
Pass a background to contrast-color() and it hands back black or white, whichever stays readable on it. The four swatches and every step of the ramp below carry the same one-line declaration — no colour was paired by hand, and none was measured. The ramp is there to find the seam: somewhere along it the label flips, and the browser decides where.
cssaccessibilitycolorprogressive enhancementcontrast-color