Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Functions

The hwb() function

Reference for the CSS hwb() function: how hue, whiteness and blackness mix, what happens when they add up to 100%, alpha, and live examples.

The hwb() function describes a color the way a painter might: pick a hue, then add whiteness (white paint) and blackness (black paint). With both at 0% you get the pure, fully vivid color; adding white gives pastels, adding black gives dark shades, and adding both gives muted tones.

Like hsl(), it is an sRGB notation, so it expresses the same colors as rgb(), just with a more intuitive set of knobs.

CSS
.chip {
  background: hwb(200 10% 5%);
}

Try it

Adding white and black

In the last row the two amounts add up to 100% or more, so the hue has no effect and you get a gray.

Syntax

CSS
hwb(H W B)
hwb(H W B / A)
hwb(from <color> H W B / A)

There is no legacy comma form and no hwba() alias. The result is a <color>.

Syntax and arguments

Argument Description
H Hue, a number (degrees) or an angle. Wraps around at 360.
W Whiteness, 0% to 100%.
B Blackness, 0% to 100%.
A Optional alpha, number 0โ€“1 or percentage.

Usage notes

  • When W + B reaches 100% or more, the two values are scaled down proportionally and the result is a gray; hue is ignored.
  • Same colors as hsl(). Any hwb() color can be written with hsl() or rgb(); choose the one that makes your edits easiest.
  • Good for tints and shades. Raise W for tints, raise B for shades, without touching hue or having to think about saturation.
  • Still not perceptually uniform. Equal changes of W do not give equal visual steps across hues.
  • Contrast. As with every notation, check text contrast against the actual rendered color.

Browser support

hwb() is supported in current versions of all major browsers; check a compatibility table if you need older ones.