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
- id: C1 claim: Relative color syntax starts from a color and computes a new one. source: S1 evidence: "take any color, and perform calculations on it to create a new color"
- id: C2 claim: The from keyword introduces the origin color. source: S1 evidence: "After the keyword from you can specify any color"
- id: C3 claim: The syntax is part of CSS Color Level 5. source: S2 evidence: "a very powerful color feature from CSS Color Level 5"
- id: C4 claim: Authors can lighten, darken, or change opacity with it. source: S2 evidence: "Lighten Darken Saturate"
Sources
- [S1] Color. web.dev. https://web.dev/learn/css/color . License: CC-BY-4.0. Accessed 2026-11-24.
- [S2] CSS relative color syntax. Chrome for Developers. https://developer.chrome.com/blog/css-relative-color-syntax . License: CC-BY-4.0. Accessed 2026-11-24.
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
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.},
}
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.
- css-relative-color.schema.json (schema; CC-BY-4.0)
- css-relative-color.table.json (table; CC-BY-4.0)
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.