hwb() CSS Function
The hwb() function defines a color by hue, whiteness and blackness, a simple way of picking a hue and then mixing in white or black.
Description
The hwb() CSS function defines an sRGB color using hue, whiteness and blackness. It is similar to hsl(), but many people find it more intuitive because it mirrors how a painter mixes color: you choose a pure hue, then add some white paint to tint it and some black paint to shade it.
The hue is an angle on the color wheel, written as a number of degrees or with an angle unit, where 0 is red, 120 is green and 240 is blue. Whiteness and blackness are percentages from 0% to 100%. With both at 0% you get the most vivid version of the hue. Increasing whiteness makes the color paler, and increasing blackness makes it darker. If whiteness and blackness add up to 100% or more, the hue no longer matters and the result is a shade of gray. An optional alpha value can be added after a slash.
.pure-orange {
background-color: hwb(30 0% 0%);
}
.pastel-orange {
background-color: hwb(30 50% 0%); /* tinted with white */
}
.brown {
background-color: hwb(30 10% 50%); /* shaded with black */
}
.translucent {
background-color: hwb(200 10% 10% / 0.6);
}
Unlike older color functions, hwb() only supports the modern space-separated syntax, with no comma-separated form. Because it describes the same sRGB colors as rgb() and hsl(), it works in all properties that accept a <color>.
Interactive Demo
Syntax
hwb() = hwb( [ from <color> ]? [ <hue> | none ]
[ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ / [ <alpha-value> | none ] ]? )
Values
- H (hue)A <hue> (number of degrees or <angle>) for the base color. 0 is red, 120 is green and 240 is blue.
- W (whiteness)A <percentage> from 0% to 100% (or a number from 0 to 100) for the amount of white mixed in.
- B (blackness)A <percentage> from 0% to 100% (or a number from 0 to 100) for the amount of black mixed in. If whiteness plus blackness is 100% or more, the result is gray.
- alphaOptional. An <alpha-value> after a slash (/) from 0 to 1, or a percentage.
Example
Browser Support
The following information will show you the current browser support for the CSS hwb() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





