Editor's Draft · filter-effects
Filter Effects 6 properties, 11 functions, 1 type defined by this
specification, 17 of them known to at least one browser
(the others are badged Not in any browser yet ).
Modern CSS features in this module: backdrop-filter .
Read the Editor's Draft ↗
Each feature in detail MDN The backdrop-filter CSS property lets you apply graphical effects such as blurring or color shifting to the area behind an element. Because it applies to everything behind the element, to see the effect the element or its background needs to be transparent or partially transparent.
Live preview Example from MDN
backdrop-filter: blur(10px); backdrop-filter: invert(80%); backdrop-filter: sepia(90%);
.example-container {
background-image : url ( "https://developer.mozilla.org/shared-assets/images/examples/balloon.jpg" );
background-size : cover ;
width : 200 px ;
height : 200 px ;
display : flex ;
align-items : center ;
justify-content : center ;
color : black ;
}
#example-element {
font-weight : bold ;
flex : 1 ;
text-align : center ;
padding : 20 px 10 px ;
background-color : rgb ( 255 255 255 / 0.2 );
} < section class = "default-example" id = "default-example" >
< div class = "example-container" >
< div id = "example-element" >Example</ div >
</ div >
</ section > Syntax none | <filter-value-list> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial none Applies to All elements. In SVG, it applies to container elements without the defs element and all graphics elements Inherited no Percentages n/a Computed value as specified Canonical order per grammar Animation type see prose in Filter Effects 1 § 14. Animation of Filters. Browser support First browser version supporting backdrop-filter Chrome 76 Edge 79 Firefox 103 Safari 18 Chrome Android 76 Safari iOS 18
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The color-interpolation-filters CSS property specifies the color space for imaging operations performed via SVG filter effects. If explicitly declared, the value of the CSS property overrides any value given in the element's color-interpolation-filters attribute.
Syntax auto | sRGB | linearRGB Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial linearRGB Applies to All filter primitives Inherited yes Percentages n/a Computed value as specified Canonical order per grammar Animation type discrete Browser support First browser version supporting color-interpolation-filters Chrome 1 Edge 79 Firefox 3 Safari 3 Chrome Android 18 Safari iOS 2
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The filter CSS property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering of images, backgrounds, and borders.
Live preview Example from MDN
filter: url("/shared-assets/images/examples/shadow.svg#element-id"); filter: blur(5px); filter: contrast(200%); filter: grayscale(80%); filter: hue-rotate(90deg); filter: drop-shadow(16px 16px 20px red) invert(75%);
.example-container {
background-color : white ;
width : 260 px ;
height : 260 px ;
display : flex ;
align-items : center ;
justify-content : center ;
}
#example-element {
flex : 1 ;
padding : 30 px ;
} < section id = "default-example" >
< div class = "example-container" >
< img
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ div >
</ section > Syntax none | <filter-value-list> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial none Applies to All elements. In SVG, it applies to container elements without the defs element, all graphics elements and the use element. Inherited no Percentages n/a Computed value as specified Canonical order per grammar Animation type See prose in Animation of Filters. Browser support First browser version supporting filter Chrome 53 Edge 12 Firefox 35 Safari 9.1 Chrome Android 53 Safari iOS 9.3
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The flood-color CSS property defines the color of the current filter primitive subregion in feFlood and feDropShadow elements within a filter. If present, it overrides the element's flood-color attribute.
Live preview Example from MDN
rect {
width : 100 px ;
height : 100 px ;
x : 10 px ;
y : 10 px ;
}
#r2 {
x : 150 px ;
}
#flood1 feFlood {
flood-color : rebeccapurple ;
}
#flood2 feFlood {
flood-color : #ff3366 ;
} < svg viewBox = "0 0 420 120" xmlns = "http://www.w3.org/2000/svg" >
< filter id = "flood1" >
< feFlood flood-color = "seagreen" />
</ filter >
< filter id = "flood2" >
< feFlood flood-color = "seagreen" />
</ filter >
< rect id = "r1" filter = "url(#flood1)" />
< rect id = "r2" filter = "url(#flood2)" />
</ svg > Syntax <color> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial black Applies to feFlood and feDropShadow elements Inherited no Percentages n/a Computed value as specified Canonical order per grammar Animation type by computed value Browser support First browser version supporting flood-color Chrome 5 Edge 12 Firefox 3 Safari 6 Chrome Android 18 Safari iOS 6
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The flood-opacity CSS property defines the opacity of the current filter primitive subregion in feFlood and feDropShadow elements within a filter. If present, it overrides the element's flood-opacity attribute.
Live preview Example from MDN
svg {
background-image : repeating-linear-gradient (
45 deg ,
transparent 0 9 px ,
#cccccc 0 px 10 px
);
}
rect {
width : 100 px ;
height : 100 px ;
x : 10 px ;
y : 10 px ;
}
#r2 {
x : 150 px ;
}
#flood1 feFlood {
flood-opacity : 0.5 ;
}
#flood2 feFlood {
flood-opacity : 90 % ;
} < svg viewBox = "0 0 420 120" xmlns = "http://www.w3.org/2000/svg" >
< filter id = "flood1" >
< feFlood flood-color = "seagreen" flood-opacity = "1" />
</ filter >
< filter id = "flood2" >
< feFlood flood-color = "seagreen" flood-opacity = "0" />
</ filter >
< rect id = "r1" filter = "url(#flood1)" />
< rect id = "r2" filter = "url(#flood2)" />
</ svg > Syntax <'opacity'> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial 1 Applies to feFlood and feDropShadow elements Inherited no Percentages n/a Computed value the specified value converted to a number, clamped to the range [0,1] Canonical order per grammar Animation type by computed value Browser support First browser version supporting flood-opacity Chrome 5 Edge 12 Firefox 3 Safari 6 Chrome Android 18 Safari iOS 6
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The lighting-color CSS property defines the color of the light source for the feDiffuseLighting and feSpecularLighting SVG lighting filter primitives within an SVG filter. If present, it overrides the element's lighting-color attribute.
Live preview Example from MDN
svg {
background-image : repeating-linear-gradient (
45 deg ,
transparent 0 9 px ,
#cccccc 0 px 10 px
);
}
rect {
width : 100 px ;
height : 100 px ;
x : 10 px ;
y : 10 px ;
}
#r2 {
x : 150 px ;
}
feDiffuseLighting {
lighting-color : blue ;
}
feSpecularLighting {
lighting-color : #ff0099 ;
} < svg viewBox = "0 0 420 120" xmlns = "http://www.w3.org/2000/svg" >
< filter id = "flood1" >
< feDiffuseLighting lighting-color = "red" >
< fePointLight x = "75" y = "30" z = "10" />
</ feDiffuseLighting >
</ filter >
< filter id = "flood2" >
< feSpecularLighting specularExponent = "5" lighting-color = "red" >
< fePointLight x = "225" y = "75" z = "5" />
</ feSpecularLighting >
</ filter >
< rect id = "r1" filter = "url(#flood1)" />
< rect id = "r2" filter = "url(#flood2)" />
</ svg > Syntax <color> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition Initial white Applies to feDiffuseLighting and feSpecularLighting elements Inherited no Percentages n/a Computed value as specified Canonical order per grammar Animation type by computed value Browser support First browser version supporting lighting-color Chrome 5 Edge 12 Firefox 3 Safari 6 Chrome Android 18 Safari iOS 6
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗
MDN The blur() CSS function applies a Gaussian blur to the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: blur(0); filter: blur(4px); filter: blur(1.5rem);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
blur( <length>? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting blur() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The brightness() CSS function applies a linear multiplier value on an element or an input image, making the image appear brighter or darker. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: brightness(1); filter: brightness(1.75); filter: brightness(50%); filter: brightness(0);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
brightness( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting brightness() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The contrast() CSS function adjusts the contrast of the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: contrast(1); filter: contrast(1.75); filter: contrast(50%); filter: contrast(0);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
contrast( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting contrast() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The drop-shadow() CSS function applies a drop shadow effect to the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: drop-shadow(30px 10px 4px #4444dd); filter: drop-shadow(0 -6mm 4mm rgb(160 0 210)); filter: drop-shadow(0 0 0.75rem crimson);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
drop-shadow( [ <color>? && <length>{2,3} ] ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting drop-shadow() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
No prose in the spec's definition and no MDN page yet: the spec link below is the only description.
Syntax filter( [ <image> | <string> ], <filter-value-list> ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Specification ↗
MDN The grayscale() CSS function converts the input image to grayscale. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: grayscale(0); filter: grayscale(0.2); filter: grayscale(60%); filter: grayscale(1);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
grayscale( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting grayscale() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The hue-rotate() CSS function rotates the hue of an element and its contents. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: hue-rotate(0); filter: hue-rotate(90deg); filter: hue-rotate(-0.25turn); filter: hue-rotate(3.142rad);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
hue-rotate( [ <angle> | <zero> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting hue-rotate() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The invert() CSS function inverts the color samples in the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: invert(0); filter: invert(0.3); filter: invert(50%); filter: invert(70%); filter: invert(1);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
invert( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting invert() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The opacity() CSS function applies transparency to the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: opacity(1); filter: opacity(80%); filter: opacity(50%); filter: opacity(0.2); filter: opacity(0);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
opacity( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting opacity() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The saturate() CSS function super-saturates or desaturates the input image. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: saturate(1); filter: saturate(4); filter: saturate(50%); filter: saturate(0);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
saturate( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting saturate() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The sepia() CSS function converts the input image to sepia, giving it a warmer, more yellow/brown appearance. It is used as a value for the filter and backdrop-filter properties.
Live preview Example from MDN
filter: sepia(0); filter: sepia(0.2); filter: sepia(60%); filter: sepia(1);
< section id = "default-example" >
< img
class = "transition-all"
id = "example-element"
src = "https://developer.mozilla.org/shared-assets/images/examples/firefox-logo.svg"
width = "200" />
</ section > Syntax /* for filter */
sepia( [ <number> | <percentage> ]? ) Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting sepia() Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Defined for filter
This feature only appears in the context of these properties, functions or types.
Specification ↗ MDN reference ↗
MDN The <filter-function> CSS data type represents a graphical effect that can change the appearance of an input image. It is used in the filter and backdrop-filter properties.
Live preview Example from MDN
CSS HTML JS
Edit Reset Copy
div {
width : 100 % ;
height : 512 px ;
background-image : url ( "https://mdn.github.io/shared-assets/images/examples/fx-nightly-512.png" );
background-repeat : no-repeat ;
background-position : center center ;
}
li {
display : flex ;
align-items : center ;
justify-content : center ;
margin-bottom : 20 px ;
}
input {
width : 60 % ;
}
output {
width : 5 % ;
text-align : center ;
}
select {
width : 40 % ;
margin-left : 2 px ;
} < div ></ div >
< ul >
< li >
< label for = "filter-select" >Choose a filter function:</ label >
< select id = "filter-select" >
< option selected >blur</ option >
< option >brightness</ option >
< option >contrast</ option >
< option >drop-shadow</ option >
< option >grayscale</ option >
< option >hue-rotate</ option >
< option >invert</ option >
< option >opacity</ option >
< option >saturate</ option >
< option >sepia</ option >
</ select >
</ li >
< li >< input type = "range" />< output ></ output ></ li >
< li >
< p >Current value: < code ></ code ></ p >
</ li >
</ ul > const selectElem = document. querySelector ( "select" );
const divElem = document. querySelector ( "div" );
const slider = document. querySelector ( "input" );
const output = document. querySelector ( "output" );
const curValue = document. querySelector ( "p code" );
selectElem. addEventListener ( "change" , () => {
setSlider (selectElem.value);
setDiv (selectElem.value);
});
slider. addEventListener ( "input" , () => {
setDiv (selectElem.value);
});
function setSlider ( filter ) {
switch (filter) {
case "blur" :
slider.value = 0 ;
slider.min = 0 ;
slider.max = 30 ;
slider.step = 1 ;
slider. setAttribute ( "data-unit" , "px" );
break ;
case "brightness" :
case "contrast" :
case "saturate" :
slider.value = 1 ;
slider.min = 0 ;
slider.max = 4 ;
slider.step = 0.05 ;
slider. setAttribute ( "data-unit" , "" );
break ;
case "drop-shadow" :
slider.value = 0 ;
slider.min = - 20 ;
slider.max = 40 ;
slider.step = 1 ;
slider. setAttribute ( "data-unit" , "px" );
break ;
case "opacity" :
slider.value = 1 ;
slider.min = 0 ;
slider.max = 1 ;
slider.step = 0.01 ;
slider. setAttribute ( "data-unit" , "" );
break ;
case "grayscale" :
case "invert" :
case "sepia" :
slider.value = 0 ;
slider.min = 0 ;
slider.max = 1 ;
slider.step = 0.01 ;
slider. setAttribute ( "data-unit" , "" );
break ;
case "hue-rotate" :
slider.value = 0 ;
slider.min = 0 ;
slider.max = 360 ;
slider.step = 1 ;
slider. setAttribute ( "data-unit" , "deg" );
break ;
default :
console. error ( "Unknown filter set" );
}
}
function setDiv ( filter ) {
const unit = slider. getAttribute ( "data-unit" );
const offset = `${ Math . round ( slider . value ) }${ unit }` ;
const radius = `${ Math . round ( Math . abs ( slider . value / 2 )) }${ unit }` ;
divElem.style.filter =
filter === "drop-shadow"
? `${ selectElem . value }(${ offset } ${ offset } ${ radius })`
: `${ selectElem . value }(${ slider . value }${ unit })` ;
updateOutput ();
updateCurValue ();
}
function updateOutput () {
output.textContent = slider.value;
}
function updateCurValue () {
curValue.textContent = `filter: ${ divElem . style . filter }` ;
}
setSlider (selectElem.value);
setDiv (selectElem.value); Syntax <blur()> | <brightness()> | <contrast()> | <drop-shadow()> | <grayscale()> | <hue-rotate()> | <invert()> | <opacity()> | <sepia()> | <saturate()> Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support First browser version supporting <filter-function> Chrome 18 Edge 12 Firefox 35 Safari 6 Chrome Android 53 Safari iOS 6
First version with support, from MDN browser-compat-data.
Specification ↗ MDN reference ↗