← All notes

CSS relative color syntax: derive a new color from another

Answer: With relative color syntax, you take any color and perform calculations on it, and that creates a new color.

The from keyword

The from keyword comes first, then any color in any syntax.

Each channel value is then available as a letter.

The oklch function works with lightness, chroma, and hue channels.

Adjust a channel with calc, or replace the channel completely.

What authors use it for

CSS Color Level 5 is where this color feature comes from.

You can lighten, darken, saturate, or desaturate the origin color.

OkLCh, the polar or cylindrical form of OKLab, uses Lightness, Chroma, and Hue.

Unlike Display P3, OkLCh is not bounded by a gamut.

Make sure you are making colors that can be displayed.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Color; Chrome for Developers, CSS relative color syntax. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, Color; Chrome for Developers, CSS relative color syntax. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://developers.google.com/site-policies). Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License. Copyright Google LLC.

Cite this

Permanent ID: iil:note:c44t8wn1

iinventedlight. 2026. "CSS relative color syntax: derive a new color from another." iinventedlight Library, iil:note:c44t8wn1, version of 2026-11-24. https://iinventedlight.com/library/notes/css-relative-color/. License: CC-BY-4.0.

@misc{iil_note_c44t8wn1,
  author = {{iinventedlight}},
  title = {{CSS relative color syntax: derive a new color from another}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/css-relative-color/},
  note = {Permanent ID iil:note:c44t8wn1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/css-relative-color.md.