Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

filter — CSS graphical effects

The filter property processes an element and its descendants as an image using effect functions or SVG filter references.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

filter: none | [ <filter-function> | <url> ]+;

filter changes the rendering of an element and its descendants as a group. It is not inherited; its initial value is none, meaning no effect. It does not change CSS box geometry.

Separate functions such as blur(4px) and invert(100%) with spaces. They run in the listed order; each result feeds the next operation. url(#effect) references an SVG filter. A nonexistent target disables the whole chain.

A value other than none creates a stacking context and a containing block for absolutely positioned and fixed descendants; the document root is exempt from the containing-block rule. This includes visually neutral blur(0px).

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>filter: invert a red swatch</title>
  <style>
    .samples {
      display: flex;
      flex-flow: row nowrap;
      gap: 0.5rem;
      max-width: calc(240px + 0.5rem);
    }
    .sample {
      flex: 1 1 120px;
      min-width: 0;
      height: 80px;
      background: #f00;
    }
    #filtered { filter: invert(100%); }
  </style>
</head>
<body>
  <div class="samples">
    <div class="sample" id="original" role="img" aria-label="Original red swatch"></div>
    <div class="sample" id="filtered" role="img" aria-label="Red swatch with an invert filter"></div>
  </div>
  <script>
    const original = document.getElementById('original');
    const filtered = document.getElementById('filtered');
    console.log(`Left filter: ${getComputedStyle(original).filter}`);
    console.log(`Right filter: ${getComputedStyle(filtered).filter}`);
  </script>
</body>
</html>

Result

Left filter: none
Right filter: invert(1)

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources