Favorites

hwb() CSS Function

hwb()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

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.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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

Colour swatch
Demo Code
HTML Code
<div class="demo-checker">
	<div class="demo-element">Colour swatch</div>
</div>
CSS Code
.demo-checker {
	width: 296px;
	padding: 18px;
	box-sizing: border-box;
	background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 20px 20px;
}
.demo-element {
	width: 260px;
	padding: 18px;
	border-radius: 8px;
	font-size: 16px;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 1px 2px rgb(0 0 0 / 40%);
	background-color: hwb(330 15% 3%);
}

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

<div class="wrap">
<h1>CSS hwb() examples</h1>
<div class="grid">
<div class="card">
<div class="sw pure"></div>
<div class="label">hwb(30 0% 0%)</div>
</div>
<div class="card">
<div class="sw tint"></div>
<div class="label">hwb(30 50% 0%)</div>
</div>
<div class="card">
<div class="sw shade"></div>
<div class="label">hwb(30 10% 50%)</div>
</div>
<div class="card">
<div class="sw blue"></div>
<div class="label">hwb(220 10% 10%)</div>
</div>
<div class="card">
<div class="sw alpha"></div>
<div class="label">hwb(220 10% 10% / 0.4)</div>
</div>
<div class="card">
<div class="sw gray"></div>
<div class="label">hwb(220 60% 40%)</div>
</div>
</div>
<p class="note">When whiteness and blackness add up to 100%, the result is gray.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* hwb() examples */
.sw {
height: 90px;
border-radius: 8px;
border: 1px solid rgba(16, 42, 67, 0.08);
}

.pure { background: hwb(30 0% 0%); }
.tint { background: hwb(30 50% 0%); }
.shade { background: hwb(30 10% 50%); }
.blue { background: hwb(220 10% 10%); }
.alpha { background: hwb(220 10% 10% / 0.4); }
.gray { background: hwb(220 60% 40%); }
Open in editor

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.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.