color()

The color() functional notation allows a color to be specified in a particular, specified colorspace rather than the implicit sRGB colorspace that most of the other color functions operate in.

Support for a particular colorspace can be detected with the color-gamut CSS media feature.

The @color-profile CSS at-rule can be used to define and names a color profile to be used in the color() function to specify a color.

Syntax

color(display-p3 1 0.5 0);
color(display-p3 1 0.5 0 / .5);

Values

Functional notation: color( [ [<ident> | <dashed-ident>]? [ <number-percentage>+ | <string> ] [ / <alpha-value> ]? ] )
[<ident> | <dashed-ident>] is an optional <ident> or dashed-ident denoting the colorspace. If this is an <ident> it denotes one of the predefined colorspaces (such as display-p3); if it is a <dashed-ident> it denotes a custom colorspace, defined by a @color-profile rule.
[ <number-percentage>+ | <string> ] is either one or more <number> or <percentage> values providing the parameter values that the colorspace takes, or a <string> giving the name of a color defined by the colorspace.
/ <alpha-value> (alpha) can be a <number> between 0 and 1, or a <percentage>, where the number 1 corresponds to 100% (full opacity).
Specification Status Comment
CSS Color Module Level 4 Working Draft Initial definition

Browser compatibility

No compatibility data found for css.types.color.color.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

See also