← Chrome 147 reference

v147 · css · covered on mdn

CSS contrast-color()

Baseline 2026 · Newly available

  • Chrome · 147
  • Edge · 147
  • Firefox · 146
  • Safari · 26

The contrast-color() web-feature is Baseline Newly available since 2026-04-10 on webstatus.dev (baseline.status: "newly", low_date: 2026-04-10; queried 2026-11-22). Chrome 147 completed the set: Safari 26 (2025-09-15) and Firefox 146 (2025-12-09) shipped first, then Chrome 147 (2026-04-07) and Edge 147 (2026-04-10). It is not yet Widely available, so keep a fallback for older browsers (see Examples).

A CSS color function that returns black or white — whichever provides greater contrast — against a given color. Useful for ensuring text remains readable regardless of a dynamic background color, without needing JavaScript or precomputed fallbacks.

this feature is documented on MDN

MDN: contrast-color()

MDN has a full reference page for contrast-color() including syntax, examples, browser compatibility, and the contrast algorithm used. gendn doesn't duplicate that here.

quick reference

Syntaxcontrast-color(<color>)
Returnswhite or black — max contrast as text on the argument (UA-defined algorithm; see Syntax)
Where usableAnywhere a <color> value is accepted
Examplecolor: contrast-color(var(--bg));
Shipped inChrome 147 (desktop + Android)
ChromeStatus4841046007742464 — CSS contrast-color()
SpecCSS Color Level 5 — contrast-color() (what Chrome 147 ships); extended form in CSS Color Level 6
Source: MDN, chromestatus, May 2026; return-value row corrected against CSS Color 5 §8, fetched 2026-11-22.

Syntax

Value definition from the CSS Color Module Level 5 editor’s draft §8, quoted verbatim (fetched 2026-11-22). This is the spec the ChromeStatus record and BCD css.types.color.contrast-color cite for the shipped function:

contrast-color() = contrast-color( <color> )

The Level 6 draft extends the function with foreground/background role keywords, a <target-contrast> and a candidate color list. That extended form is not what Chrome 147 shipped — the ChromeStatus summary describes the single-argument black/white form — so feature-detect it separately before relying on it.

Source: css-color-5 §contrast-color; css-color-6 §contrast-color (both fetched 2026-11-22); ChromeStatus 4841046007742464.

Examples

Live example from the Chrome Platform Showcase (hue-explorer concept, HTTP 200 verified 2026-11-22): drag the HSL sliders and the text flips between black and white via contrast-color().Source: chrome-platform-showcase — css-contrast-color

Readable text on a themeable background

.badge {
  --badge-bg: rebeccapurple;
  background-color: var(--badge-bg);
  color: contrast-color(var(--badge-bg)); /* resolves to white here */
}

Fallback for browsers without support

Declare a fixed color first; browsers that understand contrast-color() override it, others keep the fallback. Wrap more elaborate alternatives in @supports:

.chip {
  background-color: var(--chip-bg);
  color: black;                           /* fallback */
  color: contrast-color(var(--chip-bg));  /* Chrome 147+, Firefox 146+, Safari 26+ */
}

@supports not (color: contrast-color(red)) {
  .chip { text-shadow: 0 0 2px white; }   /* extra legibility for the fallback */
}
Source: css-color-5 §contrast-color; live hue-explorer demo.

Browser compatibility

Per-version support — BCD css/types/color.json key contrast-color (raw, fetched 2026-11-22)
BrowserVersionNotes
Chrome147Standard track, not experimental, not deprecated
Chrome Android147BCD mirror of Chrome
Edge147BCD mirror of Chrome
Firefox146Firefox for Android: mirror (146)
Safari26Safari on iOS: mirror (26)
Source: BCD css/types/color.json; webstatus.dev — contrast-color() (Baseline Newly available, 2026-04-10).

Specifications

SpecificationSection
CSS Color Module Level 5§ contrast-color()
CSS Color Module Level 6 (extended form, not shipped in Chrome 147)§ contrast-color()

See also