function

color-mix() — CSS reference

Mix colors in the selected interpolation space. Omitted weights default or complement the other weight. Explicit weights are normalized; if their sum is below 100%, the result also gets reduced alpha. The interpolation space influences both appearance and numerical result. Newer draft forms may extend the grammar.

Formal Syntax & Structure

css syntaxcss
color-mix(in <color-space>, <color> [<percentage>]?, <color> [<percentage>]?) (two-color form)

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS color lab</title><style>body {margin:0} .sample {height:12px;background:#006050}p {padding:12px;background:white;color:black;border:2px solid currentColor} #a{color:color-mix(in srgb, red, blue)} #b{color:color-mix(in srgb, red 20%, blue 20%)}
</style><body><p id="a">First color sample</p><p id="b">Second color sample</p></body></html>
CSS Reference