CSS <color> Data Type
The CSS <color> data type denotes a color that can be used in style rules. It can be specified using a color keyword, hexadecimal notation, or a color function.
When you see <color> (including the < and >) in CSS specifications and reference documentation, this indicates that the property accepts any valid CSS color value.
For example, the specification for background-color defines its syntax like this:
And your actual stylesheet code might look like this:
Possible <color> Values
A <color> can be specified using keywords, hexadecimal notation, or various color functions:
- hex-color
-
Examples:
##ff5733,##f53,##ff573380,##f538.Hexadecimal notation specifies color channels using hexadecimal digits (
0–f). CSS supports 6-digit hex values, 3-digit shorthand, 8-digit hex values with alpha, and 4-digit shorthand with alpha. - named-color
-
Examples:
red,royalblue,seagreen,goldenrod,rebeccapurple.CSS provides a standard set of 148 named colors (including
transparent). These keywords provide convenient, human-readable names for common colors. - transparent
-
Example:
background-color: transparent.A keyword representing a fully transparent color (equivalent to
rgba(0, 0, 0, 0)). - currentColor
-
Example:
border-color: currentColor.A keyword that represents the computed value of the element's
colorproperty, allowing borders, outlines, or SVGs to automatically match the text color. - system-color
-
Examples:
Canvas,CanvasText,LinkText,AccentColor,ButtonFace.Keywords that reflect the user's operating system environment and theme preferences, ensuring accessibility in high-contrast and custom OS modes.
- rgb() / rgba()
-
Examples:
rgb(255 0 0),rgb(100% 0% 0% / 0.5).Defines a color in the sRGB color space by specifying its red, green, and blue components, with an optional alpha transparency channel.
- hsl() / hsla()
-
Examples:
hsl(210 100% 50%),hsl(210 100% 50% / 0.5).Defines an sRGB color using cylindrical coordinates: hue angle (0–360°), saturation (%), and lightness (%), plus optional alpha.
- hwb()
-
Example:
hwb(210 20% 10% / 0.8).Defines an sRGB color by specifying hue, whiteness (%), and blackness (%), plus optional alpha.
- lab()
-
Example:
lab(53% 80 67).Defines a color in the CIELAB color space using Lightness, an a-axis (green-red), and a b-axis (blue-yellow). It offers perceptual uniformity across wide gamuts.
- lch()
-
Example:
lch(53% 105 40).The polar/cylindrical form of CIELAB, representing colors via Lightness, Chroma (saturation), and Hue angle.
- oklab()
-
Example:
oklab(0.63 0.22 0.13).A modern Cartesian color space designed for enhanced perceptual uniformity, fixing CIELAB's blue-shift distortions.
- oklch()
-
Example:
oklch(0.65 0.25 29).The cylindrical form of Oklab using Lightness, Chroma, and Hue. Widely considered the best color model for modern UI design tokens and palettes.
- color()
-
Examples:
color(display-p3 1 0 0),color(rec2020 0.9 0.1 0.1).Allows colors to be specified in explicit, predefined color spaces such as Display P3, Rec2020, and linear sRGB to take advantage of wide-gamut displays.
- color-mix()
-
Example:
color-mix(in oklch, royalblue 80%, white).Blends two colors together in a specified color space by a given percentage, enabling native tints, shades, and hover states.
- light-dark()
-
Example:
light-dark(white, black).Selects between two colors based on whether the computed
color-schemeis light or dark.
Official Specifications
The W3C CSS Color Module Level 4 and Level 5 specifications define <color> as follows:
Examples of Valid <color> Values
Here are examples of valid color values across the various formats:
When a property like background-color accepts a <color>, any of the above formats can be used:
Working Example
Here is an example demonstrating different color formats in action on a web page: