saturate()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

The saturate() CSS function super-saturates or desaturates the input image. Its result is a <filter-function>.

Note: saturate() is specified as a matrix operation on the RGB color. It does not actually convert the color to the HSL model, which is a non-linear operation. Therefore, it may not preserve the hue or lightness of the original color.

Try it

filter: saturate(1);
filter: saturate(4);
filter: saturate(50%);
filter: saturate(0);
<section id="default-example">
  <img
    class="transition-all"
    id="example-element"
    src="/shared-assets/images/examples/firefox-logo.svg"
    width="200" />
</section>

Syntax

css
saturate(amount)

Parameters

amount Optional

The amount of the conversion, specified as a <number> or a <percentage>. A value under 100% desaturates the image, while a value over 100% super-saturates it. A value of 0% is completely unsaturated, while a value of 100% leaves the input unchanged. The initial value for interpolation is 1. The default value is 1.

Formal syntax

<saturate()> = 
saturate( [ <number> | <percentage> ]? )

Examples

Examples of correct values for saturate()

css
saturate(0)     /* Completely unsaturated */
saturate(.4)    /* 40% saturated */
saturate()      /* No effect */
saturate(100%)  /* No effect */
saturate(200%)  /* Double saturation */

saturate() does not preserve hue or lightness

The diagram below compares two color gradients with hsl(0 50% 50%) as the mid-point: the first is generated using saturate(), and the second uses actual HSL color values. Note how the saturate() gradient shows differences in hue and lightness towards the two ends.

html
<div>
  <p>Using <code>saturate()</code></p>
  <div id="saturate"></div>
</div>
<div>
  <p>Using <code>hsl()</code></p>
  <div id="hsl"></div>
</div>
js
const saturate = document.getElementById("saturate");
const hsl = document.getElementById("hsl");

for (let i = 0; i <= 200; i++) {
  const div1 = document.createElement("div");
  div1.style.backgroundColor = `hsl(0 ${i / 2}% 50%)`;
  hsl.appendChild(div1);

  const div2 = document.createElement("div");
  div2.style.backgroundColor = "hsl(0 50% 50%)";
  div2.style.filter = `saturate(${i}%)`;
  saturate.appendChild(div2);
}

Specifications

Specification
Filter Effects Module Level 1
# funcdef-filter-saturate

Browser compatibility

See also

The other <filter-function> functions available to be used in values of the filter and backdrop-filter properties include: