function
color() — CSS reference
The color() function specifies coordinates in an explicitly named space, such as srgb, srgb-linear, display-p3 or xyz-d65. Identical numeric channels are not necessarily the same color across spaces. Relative and custom-space forms have additional grammar and support requirements.
Formal Syntax & Structure
css syntaxcss
color(<predefined-color-space> c1 c2 c3 [ / alpha ]) (absolute predefined 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(display-p3 0.2 0.4 0.6)} #b{color:color(xyz-d65 0.1 0.2 0.3)}
</style><body><p id="a">First color sample</p><p id="b">Second color sample</p></body></html>