Filter

The <filter-function> values used by filter, which applies graphical effects to an element and its content, and backdrop-filter, which applies them to whatever is behind it. Several functions can be listed together, separated by spaces, and they apply in order. The properties are under Filters, effects & masking; the image function filter() is under Shapes & images.

Blur & shadow

blur()

A Gaussian blur. The length is the blur radius (the standard deviation); larger values blur more. Percentages are not allowed, and the default is 0.

Syntaxblur( <length>? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1
.glass { background: rgb(255 255 255 / 0.4); backdrop-filter: blur(12px); }
A frosted-glass panel that blurs the content behind it.

drop-shadow()

A shadow that follows the shape of the element's visible pixels, including transparent areas of images and text, rather than its rectangular box. It takes an optional colour, x and y offsets and an optional blur radius.

Syntaxdrop-shadow( [ <color>? && <length>{2,3} ] )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

Unlike box-shadow, it has no spread value and no inset keyword. The colour defaults to currentcolor.

img.logo { filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.3)); }
A shadow around the outline of a transparent PNG or SVG logo.

Colour adjustment

brightness()

Scales the brightness linearly. 0 gives black, 1 (or 100%) leaves the colours unchanged, and larger values brighten. The default is 1.

Syntaxbrightness( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

contrast()

Adjusts contrast. 0 gives flat grey, 1 leaves the colours unchanged, and larger values increase contrast. The default is 1.

Syntaxcontrast( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

grayscale()

Converts towards greyscale. 1 (the default) is fully grey and 0 leaves the colours unchanged; values above 1 are clamped to 1.

Syntaxgrayscale( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1
img { filter: grayscale(1); transition: filter 0.3s; }
img:hover { filter: none; }
Images that turn to full colour on hover.

hue-rotate()

Rotates every colour's hue around the colour wheel by an angle. 0deg (the default) and 360deg leave colours unchanged.

Syntaxhue-rotate( [ <angle> | <zero> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

invert()

Inverts the colours. 1 (the default) is fully inverted, 0 leaves colours unchanged, and 0.5 gives flat grey. Values above 1 are clamped.

Syntaxinvert( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

opacity()

Makes the element more transparent. 1 (the default) leaves it opaque and 0 makes it fully transparent. It has the same effect as the opacity property, but can be combined with other filters in one list.

Syntaxopacity( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

saturate()

Adjusts colour saturation. 0 removes all colour, 1 (the default) leaves it unchanged, and larger values oversaturate.

Syntaxsaturate( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1

sepia()

Converts towards a warm brown sepia tone. 1 (the default) is fully sepia and 0 leaves colours unchanged; values above 1 are clamped.

Syntaxsepia( [ <number> | <percentage> ]? )
Returns<filter-function>
SupportChrome 18 · Firefox 35 · Safari 6
Specfilter-effects-1