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># |
|---|---|
| Initial | none |
| Applies to | All elements |
| Inherited | No |
| Animation | As a list of shadows; the shorter list is padded with transparent zero-size shadows |
| Support | Chrome 10 · Firefox 4 · Safari 5.1 |
| Spec | css-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 */
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.
| Syntax | none | <filter-value-list> |
|---|---|
| Initial | none |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Lists of matching filter functions interpolate function by function; see the spec for the full rules |
| Support | Chrome 53 · Firefox 35 · Safari 9.1 |
| Spec | filter-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.
| Syntax | none | <filter-value-list> |
|---|---|
| Initial | none |
| Applies to | All elements; in SVG, container elements other than <defs> and all graphics elements |
| Inherited | No |
| Animation | As for filter |
| Support | Chrome 76 · Firefox 103 · Safari 18 |
| Spec | filter-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 |
|---|---|
| Initial | normal |
| Applies to | All elements; in SVG, container elements, graphics elements and graphics referencing elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 41 · Firefox 32 · Safari 8 |
| Spec | compositing-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'># |
|---|---|
| Initial | normal |
| Applies to | All HTML elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 35 · Firefox 30 · Safari 8 |
| Spec | compositing-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> |
|---|---|
| Initial | auto |
| Applies to | All elements; in SVG, container elements, graphics elements and graphics referencing elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 41 · Firefox 36 · Safari 8 |
| Spec | compositing-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 |
|---|---|
| Initial | none |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 55 · Firefox 3.5 · Safari 9.1 |
| Spec | css-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 |
|---|---|
| Initial | auto |
| Applies to | Absolutely positioned elements; in SVG, elements that establish a new viewport, pattern elements and mask elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 1 · Safari 1 |
| Spec | css-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># |
|---|---|
| Initial | See individual properties |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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># |
|---|---|
| Initial | none |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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># |
|---|---|
| Initial | match-source |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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># |
|---|---|
| Initial | repeat |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-masking-1 |
mask-position
Where each mask image sits inside its origin box, written like background-position.
| Syntax | <position># |
|---|---|
| Initial | 0% 0% |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Percentages | Refer to the size of the mask painting area minus the size of the mask layer image, as for background-position |
| Animation | Repeatable list |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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 ]# |
|---|---|
| Initial | border-box |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-masking-1 |
mask-origin
The box that mask images are positioned and sized against, in the same way as background-origin.
| Syntax | <coord-box># |
|---|---|
| Initial | border-box |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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># |
|---|---|
| Initial | auto |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Repeatable list |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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># |
|---|---|
| Initial | add |
| Applies to | All elements; in SVG, container elements other than <defs> and all graphics elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 120 · Firefox 53 · Safari 15.4 |
| Spec | css-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'> |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | No |
| Animation | See individual properties |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-masking-1 |
mask-border-source
The image used for the mask border, as for border-image-source.
| Syntax | <'border-image-source'> |
|---|---|
| Initial | none |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-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'> |
|---|---|
| Initial | 0 |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Percentages | Refer to the size of the mask border image |
| Animation | By computed value |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-masking-1 |
mask-border-width
The width of the mask border on each side, as for border-image-width.
| Syntax | <'border-image-width'> |
|---|---|
| Initial | auto |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Percentages | Relative to the width or height of the mask border image area |
| Animation | By computed value |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-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'> |
|---|---|
| Initial | 0 |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-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'> |
|---|---|
| Initial | stretch |
| Applies to | All elements; in SVG, container elements other than <defs>, all graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome no · Firefox no · Safari 17.2 |
| Spec | css-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.
| Syntax | fill | none | [contain | cover] || scale-down |
|---|---|
| Initial | fill |
| Applies to | Replaced elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 32 · Firefox 36 · Safari 10 |
| Spec | css-images-4 |
| Value | Effect |
|---|---|
fill | Stretches the content to fill the box exactly, distorting it if the proportions differ. |
contain | Scales the content to fit inside the box with its proportions kept, leaving empty bands if needed. |
cover | Scales the content to cover the whole box with its proportions kept, cropping whatever overflows. |
none | Keeps the content at its natural size, cropped or surrounded by space. |
scale-down | Uses 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> |
|---|---|
| Initial | 50% 50% |
| Applies to | Replaced elements |
| Inherited | No |
| Percentages | Refer to the width and height of the element itself |
| Animation | As for background-position |
| Support | Chrome 32 · Firefox 36 · Safari 10 |
| Spec | css-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.
| Syntax | none | <basic-shape-rect> |
|---|---|
| Initial | none |
| Applies to | Replaced elements |
| Inherited | No |
| Animation | As <basic-shape> if possible, otherwise discrete |
| Support | Chrome 104 · Firefox no · Safari no |
| Spec | css-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.
| Syntax | auto | smooth | high-quality | pixelated | crisp-edges |
|---|---|
| Initial | auto |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 13 · Firefox 3.6 · Safari 6 |
| Spec | css-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.
| Syntax | from-image | none | [ <angle> || flip ] |
|---|---|
| Initial | from-image |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 81 · Firefox 26 · Safari 13.1 |
| Spec | css-images-3 |