CARVIEW |
Select Language
HTTP/2 200
x-guploader-uploadid: AAwnv3IcacWoDDtaDqDSBSZC0gSHsMWf0osNMHB-PzsmfZclweo-WYVfgtkADuDHYwq1S22V
x-goog-generation: 1760058399200465
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 255616
x-goog-meta-goog-reserved-file-mtime: 1760056669
x-goog-hash: crc32c=vp4FOw==, md5=R6+H0bv1tzuS5oltBxYsrw==
x-goog-storage-class: STANDARD
accept-ranges: none
expires: Mon, 13 Oct 2025 04:37:13 GMT
cache-control: public, max-age=3600
last-modified: Fri, 10 Oct 2025 01:06:39 GMT
etag: W/"47af87d1bbf5b73b92e6896d07162caf"
content-type: text/html
age: 0
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
alt-svc: clear
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
strict-transport-security: max-age=63072000
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtag/js assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net mdn.github.io live-samples.mdn.mozilla.net live-samples.mdn.allizom.net *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev interactive-examples.mdn.mozilla.net interactive-examples.mdn.allizom.net wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-frame-options: DENY
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
x-cloud-trace-context: e6ca45a1a6d3c82141013429bd19bd3c
date: Mon, 13 Oct 2025 03:37:13 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache: miss
CSS filter effects - CSS | MDN
Toggle sidebar
CSS filter effects
The properties in the CSS filter effects module let you define a way of processing an element's rendering before the element is displayed in the document. Examples of such effects include blurring and changing the intensity of the color of an element.
Filter effects in action
Play with the various sliders to apply filter effects to the image below.
<article>
<img
src="https://mdn.github.io/shared-assets/images/examples/george_floyd_memorial_sm.jpg"
width="600"
height="400"
alt="A colorful memorial honoring George Floyd and the Black Lives Matter movement" />
<form>
<fieldset>
<legend>Select your filters</legend>
<label>
<input type="range" name="blur" value="0" min="0" max="1" step="0.1" />
blur()
</label>
<label>
<input
type="range"
name="brightness"
value="1"
min="0"
max="2"
step="0.1" />
brightness()
</label>
<label>
<input
type="range"
name="contrast"
value="1"
min="0"
max="2"
step="0.1" />
contrast()
</label>
<label>
<input
type="range"
name="dropShadow"
value="0"
min="-1"
max="1"
step="0.1" />
drop-shadow()
</label>
<label>
<input
type="range"
name="grayscale"
value="0"
min="0"
max="1"
step="0.1" />
grayscale()
</label>
<label>
<input
type="range"
name="hueRotate"
value="0"
min="-1"
max="1"
step="0.1" />
hue-rotate()
</label>
<label>
<input
type="range"
name="invert"
value="0"
min="0"
max="1"
step="0.1" />
invert()
</label>
<label>
<input
type="range"
name="opacity"
value="1"
min="0"
max="1"
step="0.1" />
opacity()
</label>
<label>
<input
type="range"
name="saturate"
value="1"
min="0"
max="2"
step="0.1" />
saturate()
</label>
<label>
<input type="range" name="sepia" value="0" min="0" max="1" step="0.1" />
sepia()
</label>
<button type="reset">Reset</button>
</fieldset>
</form>
</article>
<pre><output></output></pre>
<p>Image by <cite>DigitalNomad</cite></p>
article {
display: grid;
grid-template-columns: minmax(200px, 800px) 15em;
gap: 1rem;
max-width: 100%;
}
label {
display: block;
font-family: sans-serif;
}
input {
vertical-align: middle;
margin-right: 0.25em;
max-width: 50%;
}
output {
white-space: normal;
overflow-wrap: break-word;
display: block;
width: 100%;
}
img {
margin: 1rem;
width: 100%;
object-fit: cover;
overflow: hidden;
}
const image = document.querySelector("img");
const controls = document.querySelectorAll("input");
const output = document.querySelector("output");
for (control of controls) {
control.addEventListener("change", () => {
/* do function */
changeCSS();
});
}
document.querySelector("button").addEventListener("click", () => {
setTimeout(() => {
changeCSS();
}, 50);
});
function changeCSS() {
let currentFilter = "filter: ";
for (const filter of [
blur(),
brightness(),
contrast(),
dropShadow(),
grayscale(),
hueRotate(),
invert(),
opacity(),
saturate(),
sepia(),
]) {
currentFilter += filter;
}
currentFilter += ";";
image.setAttribute("style", currentFilter);
output.innerText = currentFilter;
}
function blur() {
let blurValue = document.getElementsByName("blur")[0].value;
return blurValue === "0" ? "" : `blur(${blurValue}rem) `;
}
function brightness() {
let brightnessValue = document.getElementsByName("brightness")[0].value;
return brightnessValue.toString() === "1"
? ""
: `brightness(${brightnessValue}) `;
}
function contrast() {
let contrastValue = document.getElementsByName("contrast")[0].value;
return contrastValue === 1 ? "" : `contrast(${contrastValue}) `;
}
function dropShadow() {
let dropShadowValue = document.getElementsByName("dropShadow")[0].value;
return dropShadowValue === 0
? ""
: `drop-shadow(${dropShadowValue}rem ${dropShadowValue}rem 0rem orange) `;
}
function grayscale() {
let grayscaleValue = document.getElementsByName("grayscale")[0].value;
return grayscaleValue === 0 ? "" : `grayscale(${grayscaleValue}) `;
}
function hueRotate() {
let hueRotateValue = document.getElementsByName("hueRotate")[0].value;
return hueRotateValue === 0 ? "" : `hue-rotate(${hueRotateValue}turn) `;
}
function invert() {
let invertValue = document.getElementsByName("invert")[0].value;
return invertValue === 0 ? "" : `invert(${invertValue}) `;
}
function opacity() {
let opacityValue = document.getElementsByName("opacity")[0].value;
return opacityValue === 1 ? "" : `opacity(${opacityValue}) `;
}
function saturate() {
let saturateValue = document.getElementsByName("saturate")[0].value;
return saturateValue === 1 ? "" : `saturate(${saturateValue}) `;
}
function sepia() {
let sepiaValue = document.getElementsByName("sepia")[0].value;
return sepiaValue === 0 ? "" : `sepia(${sepiaValue})`;
}
Properties
Functions
Guides
- Using CSS filter effects
-
Overview of the concepts surrounding CSS filter effects, including properties, filter functions, and SVG filters, with an explanation of filter values, source order, and value interactions.
Related concepts
-
<image>
data type -
<filter-function>
data type -
background-image
CSS property -
background-blend-mode
CSS property -
mix-blend-mode
CSS property -
interpolation glossary term
-
color-interpolation-filters
SVG property
Specifications
Specification |
---|
Filter Effects Module Level 2> |
Filter Effects Module Level 1> |
See also
- Properties in the CSS compositing and blending module enable blending an element's background layers together and blending an element with its container
- The SVG
<filter>
element and the SVG filter primitives:<feSpotLight>
,<feBlend>
,<feColorMatrix>
,<feComponentTransfer>
,<feComposite>
,<feConvolveMatrix>
,<feDiffuseLighting>
,<feDisplacementMap>
,<feDropShadow>
,<feFlood>
,<feGaussianBlur>
,<feImage>
,<feMerge>
,<feMorphology>
,<feOffset>
,<feSpecularLighting>
,<feTile>
,<feTurbulence>