Filters, effects & masking

The properties that change how a box is painted after layout: shadows, filters, blending with what is behind it, clipping and masking, and how an image or other replaced element fits its box. The filter functions themselves are under Filter functions and the clip-path shapes under Shapes & images. Properties for SVG content, such as mask-type, clip-rule and flood-color, are under SVG; opacity is under Color & backgrounds.

Shadows

box-shadow

Draws one or more shadows around the border box, or inside the padding box with inset. Each <spread-shadow> is an optional colour, an x and y offset, an optional blur radius, an optional spread distance and the optional inset keyword. The first shadow in the list is drawn on top.

Syntax<spread-shadow>#
Initialnone
Applies toAll elements
InheritedNo
AnimationAs a list of shadows; the shorter list is padded with transparent zero-size shadows
SupportChrome 10 · Firefox 4 · Safari 5.1
Speccss-borders-4

A shadow follows border-radius and takes up no space in the layout. A positive spread grows the shadow before it is blurred; a negative spread shrinks it.

box-shadow:
  0 1px 2px rgb(0 0 0 / 0.2),   /* tight contact shadow */
  0 8px 24px -4px rgb(0 0 0 / 0.15); /* soft, lifted shadow */
Two layered shadows: offset x, offset y, blur, spread, colour.

Filters

filter

Applies graphical effects to the element and its contents as one image: blur(), brightness(), contrast(), drop-shadow(), grayscale(), hue-rotate(), invert(), opacity(), saturate() and sepia(), or a url() pointing at an SVG <filter>. A <filter-value-list> is a space-separated list of these, applied in order. See Filter functions.

Syntaxnone | <filter-value-list>
Initialnone
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationLists of matching filter functions interpolate function by function; see the spec for the full rules
SupportChrome 53 · Firefox 35 · Safari 9.1
Specfilter-effects-1

Any value other than none creates a stacking context and makes the element the containing block for its absolutely and fixed positioned descendants. Unlike box-shadow, drop-shadow() follows the shape of the visible pixels, so it works on transparent images.

backdrop-filter

Applies filter functions to whatever is painted behind the element, inside its border box. The element needs a transparent or translucent background for the effect to show; backdrop-filter: blur(12px) gives the frosted-glass look.

Syntaxnone | <filter-value-list>
Initialnone
Applies toAll elements; in SVG, container elements other than <defs> and all graphics elements
InheritedNo
AnimationAs for filter
SupportChrome 76 · Firefox 103 · Safari 18
Specfilter-effects-2

Blending

mix-blend-mode

How the element's colours combine with the content behind it. A <blend-mode> is one of normal, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color or luminosity. plus-lighter adds the colours together, which gives a clean cross-fade between two overlapping images.

Syntax<blend-mode> | plus-lighter
Initialnormal
Applies toAll elements; in SVG, container elements, graphics elements and graphics referencing elements
InheritedNo
AnimationDiscrete
SupportChrome 41 · Firefox 32 · Safari 8
Speccompositing-2

The element blends with everything in its stacking context behind it. To limit the blend to a group, set isolation: isolate on the group.

background-blend-mode

How an element's background layers blend with each other and with its background-color. It takes one blend mode per layer, in the same order as background-image. The backgrounds do not blend with content behind the element.

Syntax<'mix-blend-mode'>#
Initialnormal
Applies toAll HTML elements
InheritedNo
AnimationDiscrete
SupportChrome 35 · Firefox 30 · Safari 8
Speccompositing-2

isolation

An <isolation-mode> is auto or isolate. isolate makes the element a new stacking context, so descendants with a mix-blend-mode blend only with each other and not with what lies behind the element.

Syntax<isolation-mode>
Initialauto
Applies toAll elements; in SVG, container elements, graphics elements and graphics referencing elements
InheritedNo
AnimationDiscrete
SupportChrome 41 · Firefox 36 · Safari 8
Speccompositing-2

Clipping

clip-path

Clips the element to a shape: everything outside it is not painted and does not receive pointer events. The shape is a <basic-shape> such as circle(), ellipse(), inset(), polygon() or path(), a reference box such as border-box, or both. A <clip-source> is a url() pointing at an SVG <clipPath>.

Syntax<clip-source> | [ <basic-shape> || <geometry-box> ] | none
Initialnone
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationBy computed value
SupportChrome 55 · Firefox 3.5 · Safari 9.1
Speccss-masking-1

Two shapes of the same kind with the same number of points can be transitioned, which makes clip-path a common choice for reveal animations. See Shapes & images for the shape functions.

clip Deprecated

Clips an absolutely positioned element to a rectangle given by rect(). It is deprecated: use clip-path instead, for example clip-path: inset(50%).

Syntax<rect()> | auto
Initialauto
Applies toAbsolutely positioned elements; in SVG, elements that establish a new viewport, pattern elements and mask elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-masking-1

Masking

mask

Shorthand for the mask-* longhands below. Like background, it takes a comma-separated list of layers, and each <mask-layer> sets an image, position, size, repeat, origin, clip, compositing operator and mode. Where the mask is opaque (or bright, in luminance mode) the element shows; where it is transparent the element is hidden.

Syntax<mask-layer>#
InitialSee individual properties
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-image

The images used as mask layers. A <mask-reference> is none, an <image> such as a gradient or url() to an image file, or a url() pointing at an SVG <mask> element. A gradient to transparent fades the element out.

Syntax<mask-reference>#
Initialnone
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-mode

Whether each mask layer is read by its alpha channel or its luminance. A <masking-mode> is alpha, luminance or match-source, which uses the SVG <mask> element's mask-type for mask references and alpha for images.

Syntax<masking-mode>#
Initialmatch-source
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-repeat

How mask images tile. It takes the same values as background-repeat: repeat, no-repeat, repeat-x, repeat-y, space and round.

Syntax<repeat-style>#
Initialrepeat
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-position

Where each mask image sits inside its origin box, written like background-position.

Syntax<position>#
Initial0% 0%
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
PercentagesRefer to the size of the mask painting area minus the size of the mask layer image, as for background-position
AnimationRepeatable list
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-clip

The area the mask affects; outside it the element is hidden. A <coord-box> is content-box, padding-box, border-box, or for SVG fill-box, stroke-box or view-box. no-clip leaves the painted area unclipped.

Syntax[ <coord-box> | no-clip ]#
Initialborder-box
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-origin

The box that mask images are positioned and sized against, in the same way as background-origin.

Syntax<coord-box>#
Initialborder-box
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-size

The size of each mask image, written like background-size: auto, cover, contain, or one or two lengths or percentages.

Syntax<bg-size>#
Initialauto
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationRepeatable list
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

mask-composite

How each mask layer combines with the layers below it. A <compositing-operator> is add (union), subtract (cut this layer out of the ones below), intersect (keep only the overlap) or exclude (keep everything but the overlap).

Syntax<compositing-operator>#
Initialadd
Applies toAll elements; in SVG, container elements other than <defs> and all graphics elements
InheritedNo
AnimationDiscrete
SupportChrome 120 · Firefox 53 · Safari 15.4
Speccss-masking-1

Mask border

mask-border

Shorthand for a mask that is sliced and stretched over the element's edges in the same way as border-image, so a small image can mask a box of any size. Only Safari ships the unprefixed properties.

Syntax<'mask-border-source'> || <'mask-border-slice'> [ / <'mask-border-width'>? [ / <'mask-border-outset'> ]? ]? || <'mask-border-repeat'> || <'mask-border-mode'>
InitialSee individual properties
Applies toSee individual properties
InheritedNo
AnimationSee individual properties
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

mask-border-source

The image used for the mask border, as for border-image-source.

Syntax<'border-image-source'>
Initialnone
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

mask-border-slice

Where to cut the mask border image into corners, edges and a middle, as for border-image-slice.

Syntax<'border-image-slice'>
Initial0
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
PercentagesRefer to the size of the mask border image
AnimationBy computed value
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

mask-border-width

The width of the mask border on each side, as for border-image-width.

Syntax<'border-image-width'>
Initialauto
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
PercentagesRelative to the width or height of the mask border image area
AnimationBy computed value
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

mask-border-outset

How far the mask border area extends beyond the border box, as for border-image-outset.

Syntax<'border-image-outset'>
Initial0
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationBy computed value
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

mask-border-repeat

How the edge and middle slices of the mask border image fill their areas: stretched, repeated, rounded or spaced, as for border-image-repeat.

Syntax<'border-image-repeat'>
Initialstretch
Applies toAll elements; in SVG, container elements other than <defs>, all graphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome no · Firefox no · Safari 17.2
Speccss-masking-1

Replaced content

object-fit

How the content of a replaced element, such as an <img> or <video>, is sized to fit its box when the two have different proportions.

Syntaxfill | none | [contain | cover] || scale-down
Initialfill
Applies toReplaced elements
InheritedNo
AnimationDiscrete
SupportChrome 32 · Firefox 36 · Safari 10
Speccss-images-4
ValueEffect
fillStretches the content to fill the box exactly, distorting it if the proportions differ.
containScales the content to fit inside the box with its proportions kept, leaving empty bands if needed.
coverScales the content to cover the whole box with its proportions kept, cropping whatever overflows.
noneKeeps the content at its natural size, cropped or surrounded by space.
scale-downUses none or contain, whichever gives the smaller result, so the content is never enlarged.

Pair object-fit: cover with a fixed aspect-ratio on the image for uniform thumbnails; object-position chooses which part stays in view.

object-position

Where the content of a replaced element sits inside its box, written like background-position. It decides which part is cropped with object-fit: cover, or where the spare space goes with contain.

Syntax<position>
Initial50% 50%
Applies toReplaced elements
InheritedNo
PercentagesRefer to the width and height of the element itself
AnimationAs for background-position
SupportChrome 32 · Firefox 36 · Safari 10
Speccss-images-3

object-view-box

Selects a rectangle of a replaced element's content to show, as if the content were cropped to it before object-fit applies. A <basic-shape-rect> is inset(), rect() or xywh(). Animating it gives a zoom or pan.

Syntaxnone | <basic-shape-rect>
Initialnone
Applies toReplaced elements
InheritedNo
AnimationAs <basic-shape> if possible, otherwise discrete
SupportChrome 104 · Firefox no · Safari no
Speccss-images-5

image-rendering

How an image is scaled. auto lets the browser smooth it; pixelated and crisp-edges keep hard edges, which suits pixel art and QR codes scaled up.

Syntaxauto | smooth | high-quality | pixelated | crisp-edges
Initialauto
Applies toAll elements
InheritedYes
AnimationDiscrete
SupportChrome 13 · Firefox 3.6 · Safari 6
Speccss-images-3

image-orientation

Whether images are rotated according to the orientation stored in their metadata, as cameras record it. from-image, the default, honours it; none shows the image as encoded.

Syntaxfrom-image | none | [ <angle> || flip ]
Initialfrom-image
Applies toAll elements
InheritedYes
AnimationDiscrete
SupportChrome 81 · Firefox 26 · Safari 13.1
Speccss-images-3