CSS color-interpolation-filters Property

The color-interpolation-filters property specifies the color space used when processing color values in SVG filter primitives.

It determines whether applicable filter operations use standard sRGB or linear-light RGB color calculations. This can affect the appearance of effects such as color blending, compositing, and color transformations.

The property is primarily used with SVG filters and supports three values: auto, sRGB, and linearRGB. Its initial value is linearRGB, unlike the related color-interpolation property, which initially uses sRGB.

color-interpolation-filters Syntax

The color-interpolation-filters property accepts a keyword specifying the color space used by applicable SVG filter operations.

selector {
  color-interpolation-filters: sRGB;
}

General Syntax

selector {
  color-interpolation-filters: auto | sRGB | linearRGB;
}

Automatic Color Processing

.svg-filter-effect {
  color-interpolation-filters: auto;
}

sRGB Color Processing

.svg-filter-effect {
  color-interpolation-filters: sRGB;
}

Linear RGB Color Processing

.svg-filter-effect {
  color-interpolation-filters: linearRGB;
}

SVG Presentation Attribute

<feBlend in="SourceGraphic" in2="BackgroundImage" mode="multiply" color-interpolation-filters="sRGB"></feBlend>

CSS-Wide Keywords

.svg-filter-effect {
  color-interpolation-filters: inherit;
}
.svg-filter-effect {
  color-interpolation-filters: initial;
}
.svg-filter-effect {
  color-interpolation-filters: unset;
}
.svg-filter-effect {
  color-interpolation-filters: revert;
}
.svg-filter-effect {
  color-interpolation-filters: revert-layer;
}

Property Values

The property supports three values for controlling SVG filter color processing.

Value Description
auto Allows the browser to select the color interpolation space. For SVG filter primitives, this generally resolves to linearRGB behavior.
sRGB Processes applicable filter color values in the standard sRGB color space.
linearRGB Processes applicable filter color values in linear-light RGB. This is the initial value.

CSS-Wide Keywords

Value Description
inherit Uses the computed value from the parent element.
initial Resets the property to linearRGB.
unset Uses the inherited value because the property is inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value linearRGB
Inherited Yes
Applies to SVG filter primitives
Computed value As specified
Animation type Discrete
Percentages Not applicable
Primary use Controlling SVG filter color calculations

The property does not accept arbitrary CSS color spaces such as oklch, lab, or display-p3.

How It Works

SVG filter primitives process graphical input to produce visual effects. The color-interpolation-filters property determines which RGB color space is used for applicable color calculations.

Step 1: Define an SVG Filter

<filter id="example-filter">
  <feComponentTransfer>
    <feFuncR type="gamma" amplitude="1" exponent="2" offset="0"></feFuncR>
    <feFuncG type="gamma" amplitude="1" exponent="2" offset="0"></feFuncG>
    <feFuncB type="gamma" amplitude="1" exponent="2" offset="0"></feFuncB>
  </feComponentTransfer>
</filter>

Step 2: Select a Color Space

.custom-transfer {
  color-interpolation-filters: sRGB;
}

Apply the class to the SVG filter primitive to control how its color channels are processed.

Step 3: Process the Input Colors

The browser converts the filter input into the selected color space as needed before performing the primitive's color calculations.

Step 4: Produce the Filter Output

The filter generates output colors according to its operation and selected color space.

Step 5: Render the Result

The browser displays the filtered graphic. Switching between sRGB and linearRGB can change its brightness, blending, or color balance.

Not every filter primitive produces a visible difference. The effect depends on the operation and input colors.

auto Value

The auto value allows the browser to select the interpolation color space used by applicable SVG filter operations.

.svg-filter-effect {
  color-interpolation-filters: auto;
}

Automatic Selection

For SVG filter processing, auto generally produces behavior equivalent to linearRGB.

SVG Example

<feComponentTransfer color-interpolation-filters="auto">
  <feFuncR type="gamma" amplitude="1" exponent="2" offset="0"></feFuncR>
  <feFuncG type="gamma" amplitude="1" exponent="2" offset="0"></feFuncG>
  <feFuncB type="gamma" amplitude="1" exponent="2" offset="0"></feFuncB>
</feComponentTransfer>

When to Use auto

Use auto when the exact interpolation space is not important and browser-selected behavior is acceptable.

Explicit Color Spaces

For predictable filter rendering, specify sRGB or linearRGB directly.

sRGB Value

The sRGB value instructs applicable SVG filter primitives to perform color calculations using standard sRGB channel values.

.svg-filter-effect {
  color-interpolation-filters: sRGB;
}

Gamma-Encoded Color Processing

sRGB channel values are encoded nonlinearly. Operations performed directly on these values can produce different results than calculations performed in linear-light RGB.

SVG Example

<feComponentTransfer color-interpolation-filters="sRGB">
  <feFuncR type="gamma" amplitude="1" exponent="2" offset="0"></feFuncR>
  <feFuncG type="gamma" amplitude="1" exponent="2" offset="0"></feFuncG>
  <feFuncB type="gamma" amplitude="1" exponent="2" offset="0"></feFuncB>
</feComponentTransfer>

Filter Appearance

For some color transformations, sRGB processing can produce darker results than linearRGB processing. The exact difference depends on the filter operation.

When to Use sRGB

Use sRGB when a filter effect should operate directly on conventional RGB channel values or when matching a particular existing SVG rendering.

Override the Default

Because the initial value is linearRGB, specifying sRGB explicitly is necessary when you want sRGB filter processing.

linearRGB Value

The linearRGB value processes applicable SVG filter colors using linear-light RGB values.

.svg-filter-effect {
  color-interpolation-filters: linearRGB;
}

Linear-Light Color Processing

Linear RGB channel values are proportional to light intensity, making them useful for operations that combine or transform light contributions.

SVG Example

<feComponentTransfer color-interpolation-filters="linearRGB">
  <feFuncR type="gamma" amplitude="1" exponent="2" offset="0"></feFuncR>
  <feFuncG type="gamma" amplitude="1" exponent="2" offset="0"></feFuncG>
  <feFuncB type="gamma" amplitude="1" exponent="2" offset="0"></feFuncB>
</feComponentTransfer>

Initial Value

The initial value of color-interpolation-filters is linearRGB. Explicitly specifying it is useful when overriding an inherited setting.

Blending and Compositing

Linear-light processing can produce different results when colors are combined, especially for partially transparent or strongly contrasting colors.

When to Use linearRGB

Use linearRGB when the filter should operate in linear-light RGB or when the standard SVG filter behavior is appropriate.

The property controls the color space used for processing. It does not change the specified source colors themselves.

Color Space Differences

The difference between sRGB and linearRGB comes from how RGB channel values represent light.

sRGB

sRGB uses a nonlinear transfer function designed for common display and image workflows.

linearRGB

Linear RGB removes the nonlinear encoding so channel values are proportional to light intensity.

Example: Midpoint Between Black and White

Consider an operation that averages black and white with equal weighting.

Color Space Approximate Displayed Midpoint
sRGB rgb(128 128 128)
linearRGB rgb(188 188 188)

This illustrates why linear-light calculations can appear brighter when colors are averaged. Actual SVG filter results depend on the specific primitive and its mathematical operation.

Color Conversion

The browser converts colors into the selected processing space before performing applicable filter calculations.

Final Display

After filter processing, the resulting colors are converted as needed for display.

Choosing a Color Space

Select the space based on the intended appearance and test the completed filter effect rather than assuming one space always produces better results.

SVG Filter Primitives

SVG filters contain filter primitives that perform operations on graphical input. The color-interpolation-filters property can control the color space used by these primitives.

feBlend

The feBlend primitive combines two input images using a blending mode.

<feBlend in="SourceGraphic" in2="BackgroundImage" mode="multiply" color-interpolation-filters="sRGB"></feBlend>

feComposite

The feComposite primitive combines two inputs using compositing operations.

<feComposite in="SourceGraphic" in2="BackgroundImage" operator="over" color-interpolation-filters="linearRGB"></feComposite>

feColorMatrix

The feColorMatrix primitive transforms color channels using a matrix or predefined transformation.

<feColorMatrix type="saturate" values="0.5" color-interpolation-filters="sRGB"></feColorMatrix>

feComponentTransfer

The feComponentTransfer primitive applies channel-specific transfer functions.

<feComponentTransfer color-interpolation-filters="linearRGB">
  <feFuncR type="linear" slope="1.2" intercept="0"></feFuncR>
  <feFuncG type="linear" slope="1" intercept="0"></feFuncG>
  <feFuncB type="linear" slope="1" intercept="0"></feFuncB>
</feComponentTransfer>

feFlood

The feFlood primitive generates a solid-color image that can be used as input to other filter operations.

<feFlood flood-color="#1769aa" flood-opacity="0.7" result="flood"></feFlood>

feGaussianBlur

The feGaussianBlur primitive blurs its input. Color-space selection can affect how colored pixels are combined during blur processing.

<feGaussianBlur stdDeviation="4" color-interpolation-filters="linearRGB"></feGaussianBlur>

Primitive-Specific Behavior

Some primitives operate primarily on geometry or alpha information, so changing the color interpolation space may produce little or no visible difference.

The property does not guarantee a visible change for every SVG filter primitive.

Filter Blending

Blending combines colors from two graphical inputs. The selected interpolation space can influence the resulting colors.

sRGB Blending

.blend-srgb {
  color-interpolation-filters: sRGB;
}

Linear RGB Blending

.blend-linear {
  color-interpolation-filters: linearRGB;
}

SVG Blend Primitive

<feBlend in="SourceGraphic" in2="background" mode="screen" color-interpolation-filters="linearRGB"></feBlend>

Why Results Differ

Blending operations use mathematical calculations on color channels. Because sRGB and linearRGB represent channel values differently, the resulting displayed colors may differ.

Transparency

Alpha values are handled separately from RGB color-space conversion. Filter compositing also uses alpha information when combining graphical inputs.

Visual Consistency

When matching filter effects across multiple SVG graphics, use the same interpolation setting and test the results with the actual colors involved.

SVG Presentation Attribute

SVG supports color-interpolation-filters as a presentation attribute, allowing it to be specified directly on a filter primitive.

Attribute Example

<feColorMatrix type="saturate" values="0.5" color-interpolation-filters="sRGB"></feColorMatrix>

CSS Equivalent

.custom-color-matrix {
  color-interpolation-filters: sRGB;
}

Class-Based Styling

<feColorMatrix class="custom-color-matrix" type="saturate" values="0.5"></feColorMatrix>

CSS Cascade

A CSS declaration normally takes precedence over an SVG presentation attribute when both specify the same property on the same element.

Inline SVG

Presentation attributes are convenient for self-contained SVG graphics, while CSS classes can make repeated filter styles easier to maintain.

SVG Element Capitalization

SVG uses element names such as feColorMatrix and feComponentTransfer. When SVG is embedded in an HTML document, lowercase element names are recognized by the HTML parser. Standalone SVG files use XML parsing and require the official capitalization.

Inheritance

The color-interpolation-filters property is inherited, allowing SVG filter primitives to use a setting established by an ancestor.

Set the Property on a Filter

.custom-filter {
  color-interpolation-filters: sRGB;
}

Override a Primitive

.custom-filter {
  color-interpolation-filters: sRGB;
}
.custom-filter .linear-primitive {
  color-interpolation-filters: linearRGB;
}

Explicit Inheritance

.filter-primitive {
  color-interpolation-filters: inherit;
}

Reset to Initial Value

.filter-primitive {
  color-interpolation-filters: initial;
}

The initial keyword resets the property to linearRGB.

Scope the Declaration

For predictable results, specify the property on the filter primitive or its relevant SVG ancestor.

Inherited values can simplify SVG filter styling, but explicit declarations are useful when different primitives require different color spaces.

Comparison with color-interpolation

The color-interpolation-filters and color-interpolation properties serve different purposes in SVG rendering.

Feature color-interpolation-filters color-interpolation
Primary purpose SVG filter color processing Applicable SVG color interpolation, including gradients
Initial value linearRGB sRGB
Values auto, sRGB, linearRGB auto, sRGB, linearRGB
Inherited Yes Yes
Typical application Filter primitives SVG gradients

Filter Processing

.svg-filter {
  color-interpolation-filters: sRGB;
}

Gradient Interpolation

.svg-gradient {
  color-interpolation: linearRGB;
}

Different Defaults

The initial value of color-interpolation-filters is linearRGB, while color-interpolation initially uses sRGB.

Choosing the Correct Property

Use color-interpolation-filters for SVG filter primitives and color-interpolation for applicable SVG color interpolation outside filter processing.

CSS filter Property

The CSS filter property applies graphical effects to elements. These effects can be built-in CSS filter functions or references to SVG filters.

CSS Filter Function

.image {
  filter: grayscale(50%);
}

Multiple CSS Filter Functions

.image {
  filter: brightness(1.2) contrast(1.1);
}

SVG Filter Reference

.image {
  filter: url(#custom-filter);
}

SVG Filter Color Space

<filter id="custom-filter">
  <feColorMatrix type="saturate" values="0.5" color-interpolation-filters="sRGB"></feColorMatrix>
</filter>

Important Difference

The color-interpolation-filters property controls color processing within applicable SVG filter primitives. It does not provide a general color-space setting for every built-in CSS filter function.

When precise filter color processing is required, an SVG filter provides more direct control over the relevant primitives.

Practical Uses

The color-interpolation-filters property is useful when SVG filter effects require specific color processing behavior.

Color Transformations

.color-transform {
  color-interpolation-filters: sRGB;
}

Use sRGB when color transformations should operate on conventional RGB channel values.

Linear-Light Effects

.linear-effect {
  color-interpolation-filters: linearRGB;
}

Use linearRGB when filter calculations should be performed using linear-light color values.

Reusable SVG Filters

.filter-standard {
  color-interpolation-filters: sRGB;
}
.filter-linear {
  color-interpolation-filters: linearRGB;
}

Matching Existing Graphics

When reproducing an existing SVG effect, selecting the correct color interpolation space can help match the original rendering.

Image Processing

SVG filters can be applied to HTML images through the CSS filter property. The SVG filter primitives can use color-interpolation-filters to control their color calculations.

Visual Testing

Compare the same filter effect using sRGB and linearRGB to determine which produces the intended appearance.

color-interpolation-filters Example

The following example compares two SVG filter effects that apply the same gamma transformation to a medium-gray rectangle. One filter processes color channels in sRGB, while the other uses linearRGB.

The difference is visible because the transformation operates on different channel values in the two color spaces.

<div class="filter-interpolation-demo">
  <div class="filter-item">
    <p>sRGB</p>
    <svg viewBox="0 0 220 100" role="img" aria-label="Gray rectangle processed using an sRGB filter">
      <defs>
        <filter id="demo-filter-srgb" x="0" y="0" width="100%" height="100%">
          <fecomponenttransfer color-interpolation-filters="sRGB">
            <fefuncr type="gamma" amplitude="1" exponent="2" offset="0"></fefuncr>
            <fefuncg type="gamma" amplitude="1" exponent="2" offset="0"></fefuncg>
            <fefuncb type="gamma" amplitude="1" exponent="2" offset="0"></fefuncb>
          </fecomponenttransfer>
        </filter>
      </defs>
      <rect width="220" height="100" fill="#808080" filter="url(#demo-filter-srgb)"></rect>
    </svg>
  </div>
  <div class="filter-item">
    <p>linearRGB</p>
    <svg viewBox="0 0 220 100" role="img" aria-label="Gray rectangle processed using a linear RGB filter">
      <defs>
        <filter id="demo-filter-linear" x="0" y="0" width="100%" height="100%">
          <fecomponenttransfer color-interpolation-filters="linearRGB">
            <fefuncr type="gamma" amplitude="1" exponent="2" offset="0"></fefuncr>
            <fefuncg type="gamma" amplitude="1" exponent="2" offset="0"></fefuncg>
            <fefuncb type="gamma" amplitude="1" exponent="2" offset="0"></fefuncb>
          </fecomponenttransfer>
        </filter>
      </defs>
      <rect width="220" height="100" fill="#808080" filter="url(#demo-filter-linear)"></rect>
    </svg>
  </div>
</div>
.filter-interpolation-demo {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 25px;
}
.filter-interpolation-demo .filter-item {
  width: 220px;
  max-width: 100%;
}
.filter-interpolation-demo .filter-item p {
  margin-bottom: 8px;
  font-weight: bold;
  text-align: center;
}
.filter-interpolation-demo svg {
  display: block;
  width: 100%;
  height: auto;
}
Browser Result

sRGB

linearRGB

The sRGB filter produces a darker gray because the gamma transformation is applied directly to the encoded sRGB channel values. The linearRGB filter produces a different result because the transformation operates on linear-light values.

Both filters use the same source color and gamma settings. Only the color processing space changes.

Important Considerations

Keep the following points in mind when using color-interpolation-filters:

  • Purpose: Controls the color space used for applicable SVG filter calculations.
  • Initial value: linearRGB.
  • Inheritance: The property is inherited.
  • Values: Supports auto, sRGB, and linearRGB.
  • auto: Allows browser-selected color processing, generally equivalent to linearRGB for SVG filters.
  • sRGB: Processes color values using gamma-encoded RGB channels.
  • linearRGB: Processes color values using linear-light RGB channels.
  • SVG filters: The property applies to SVG filter primitives.
  • Color transformations: The selected space can affect color matrix and component transfer operations.
  • Blending: Some blending operations produce different results in sRGB and linearRGB.
  • Compositing: Filter compositing may depend on the selected color space.
  • Primitive behavior: Some primitives may show little or no visible difference.
  • Presentation attributes: The property can be specified directly in SVG markup.
  • CSS cascade: CSS declarations can override SVG presentation attributes.
  • CSS filter functions: The property is not a general color-space control for built-in CSS filter functions.
  • SVG gradients: Use color-interpolation for applicable SVG gradient interpolation.
  • Animation: Changes between property values are discrete.
  • Browser support: Test SVG filter effects in the browsers relevant to your project.

Use color-interpolation-filters when the color space of an SVG filter operation affects the intended appearance. Apply the setting to the relevant filter primitive and verify the rendered result.

Browser Support

The color-interpolation-filters property is supported in modern browsers for SVG filter processing, including Chrome, Edge, Firefox, and Safari. The visible effect depends on the filter primitive and the colors being processed.

Support for SVG filter operations is separate from support for built-in CSS filter functions. The property should be tested with the actual SVG filter used by the page.

SVG Filter Example

.svg-filter-effect {
  color-interpolation-filters: sRGB;
}

SVG Presentation Attribute

<feColorMatrix type="saturate" values="0.5" color-interpolation-filters="sRGB"></feColorMatrix>

Compatibility Considerations

For predictable rendering, test the completed SVG filter in target browsers. A supported property may still produce different visual results depending on the filter operation and browser implementation.

For current compatibility information, visit Can I Use? and search for color-interpolation-filters.

Specifications

The color-interpolation-filters property is defined in the Filter Effects specification.

Filter Effects Module Level 1

The specification defines the property's values, inheritance, initial value, and behavior during SVG filter color processing.