Skip to main content

Harshal V. LADHE

CSS contrast-color() Function

Choosing readable white or black text for any background colour with CSS `contrast-color()`, its limits and fallbacks.

Content tagged contrast-color

  • Tutorial:contrast-color(): Automatic Readable Text on Any Background

    Let CSS choose readable white or black text automatically.
    Use CSS contrast-color() to pick white or black text for any background colour: how the spec defines it, custom properties and brand colours, buttons and tags, pairing with light-dark(), mid-tone limits, and an @supports fallback.
    Published at:
    Categories:CSS
    Estimated reading time:10 min read