The CSS filter property applies graphical effects such as blur, grayscale and brightness to an element and everything inside it. For example, filter: blur(4px) grayscale(100%); softens an image and removes its color. Each effect is a function, and you can chain several, separated by spaces.
Using css filter blur grayscale effects avoids image editing for hover states, disabled looks and background dimming. This guide explains the filter functions, the order of chained effects, backdrop-filter for frosted glass, and the performance costs.
filter takes none or a space-separated list of filter functions. The browser renders the element first, then runs the filters on the result.
Filters work on any element, not only images: text, buttons, SVG and whole sections. Like opacity, a filter other than none creates a new stacking context.
| Function | Argument | Effect |
|---|---|---|
blur() | Length such as 4px | Gaussian blur; the value is the standard deviation |
grayscale() | 0 to 1 or 0% to 100% | Removes color |
brightness() | Number or percent; 1 is unchanged | Values below 1 darken, above 1 brighten |
contrast() | Number or percent; 1 is unchanged | Lowers or raises contrast |
saturate() | Number or percent; 1 is unchanged | Washes out or intensifies color |
sepia() | 0 to 1 | Warm, brownish vintage tone |
hue-rotate() | Angle such as 90deg | Shifts all hues around the color wheel |
invert() | 0 to 1 | Inverts colors |
opacity() | 0 to 1 | Like the opacity property, but filter-based |
drop-shadow() | Offsets, blur, color | Shadow that follows the visible shape |
A common pattern is a disabled or "unavailable" product image: filter: grayscale(1) opacity(0.6);. Another is dimming a background photo so text on top is readable: filter: brightness(0.5);.
Filters run left to right, each one taking the previous result as input. Changing the order can change the output.
These two rules produce different pictures, because contrast and brightness are not commutative. When you animate between two filter lists, keep the same functions in the same order in both states. Otherwise the browser cannot interpolate them and the change jumps instead of fading.
box-shadow always follows the rectangular box. drop-shadow() follows the real alpha shape of what is drawn, so it suits transparent PNGs, SVG icons and clipped shapes.
Its arguments are offset-x, offset-y, an optional blur and a color. Unlike box-shadow, it has no spread value and no inset option.
filter changes the element itself. backdrop-filter changes what is visible behind the element, so you can make a frosted-glass panel. The element needs a partly transparent background to show the effect.
backdrop-filter is supported in current versions of all major browsers. For older ones, provide a solid or more opaque background as a fallback with @supports:
brightness(), contrast() or opacity() to text.Not directly, because filter affects the whole element. Put the background on a pseudo-element such as ::before and filter that instead.
They look the same, but the filter version can be combined in a chain and is applied in order with the other functions. For a plain fade, the opacity property is simpler.
Blur spreads pixels outward, and a parent with overflow: hidden clips them. Add some padding or a slight scale, for example transform: scale(1.05) on a blurred background image.
Yes. It works on any rendered element, including <img>, <video> and inline SVG, and you can reference an SVG filter with filter: url(#id) for custom effects.
The filter property chains functions such as blur(), grayscale() and brightness() from left to right, so order matters. Use drop-shadow() to follow transparent shapes, backdrop-filter for frosted glass with a fallback, and keep blur radii small to protect performance.