CSS colors
TheCSS colors module defines colors, color types, color blending, opacity, and how you can apply these colors and effects to HTML content.
While this module has only two CSS properties,color andopacity, over 20 CSS and SVG properties, CSS images, at-rules, and @media rules depend on these two properties.
In this article
Colors in action
The color syntax converter below shows the values of the currently selected color inred-green-blue (RGB),hexadecimal (HEX),hue, saturation, and lightness (HSL), andhue, whiteness, and blackness (HWB) CSS color formats. All the RGB, HEX, HSL, and HWB color values here, while written differently, represent the same color value.
Selecting a color via thecolor picker and an opacity via theslider updates the RGB, HEX, HSL, and HWB values. When you choose a new color or opacity value, the color of the background and the slider update via the CSS propertiesbackground-color andaccent-color, respectively.
To see the code for this color syntax converter,view the source on GitHub.
Reference
>Properties
At-rules and descriptors
The CSS colors module also introduces the@color-profile at-rule, along with itscomponents,rendering-intent andsrc descriptors. Currently, no browsers support these features.
Functions
- Color functions:
color-mix()contrast-color()light-dark()
The CSS color modules also introduce thedevice-cmyk() function. Currently, no browsers support this feature.
Data types
Glossary terms and keywords
Interfaces
The CSS color module also introduces theCSSColorProfileRule interface. Currently, no browsers support this feature.
Guides
- Applying color to HTML elements using CSS
A guide to using CSS to apply color to a variety of types of content, including all CSS properties that accept
<color>as a value.- CSS color values
An overview of color spaces and the different
<color>functional notations available in CSS.- Using color wisely
Color theory and resources, including finding the right colors to create an accessible color palette, contrast, and printing in color.
- Using relative colors
This article explains relative CSS color syntax, shows what the different options are, and looks at some illustrative examples.
- Understanding color and luminance
Color perception and using colors with color insensitive (color blind) users, reduced vision users and users with vestibular disorders or other neurological disorders in mind.
- WCAG 1.4.1: Color contrast
Explanation of contrast requirements between background and foreground content to ensure legibility.
- CSS value serialization
HowCSSOM APIs serialize color and other values into standardized string representations.
Related concepts
- CSS properties that are part of other specifications:
dynamic-range-limit-mix()function- SVG color properties that are part of other specifications:
- SVG
colorattribute - Color wheel glossary term
- Interpolation glossary term
- The
@font-palette-valuesat-ruleoverride-colorsdescriptor - The
@color-profileat-rule - The
color-gamut@media feature - The
forced-colors@media feature
Specifications
| Specification |
|---|
| CSS Color Module Level 4> |
| CSS Color Module Level 5> |
See also
- CSS color adjustment module and
print-color-adjust <gradient>defined inCSS images module- The
VideoColorSpaceinterface <feColorMatrix>SVG element- Canvas API: applying styles and colors
- Tools: