Candidate Recommendation Draft · css-masking

CSS Masking

20 properties defined by this specification, 19 of them known to at least one browser (the others are badged Not in any browser yet).

Each feature in detail

clip

Property Deprecated

MDN The clip CSS property defines a visible portion of an element. The clip property applies only to absolutely positioned elements — that is, elements with position:absolute or position:fixed.

Live preview Example from MDN
.dotted-border {
  border: dotted;
  position: relative;
  width: 390px;
  height: 400px;
}

#top-left,
#middle,
#bottom-right {
  position: absolute;
  top: 0;
}

#top-left {
  left: 400px;
  clip: rect(0, 130px, 90px, 0);
}

#middle {
  left: 270px;
  clip: rect(100px, 260px, 190px, 130px);
}

#bottom-right {
  left: 140px;
  clip: rect(200px, 390px, 290px, 260px);
}

Syntax

<rect()> | auto

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
Absolutely positioned elements. In SVG, it applies to elements which establish a new viewport, pattern elements and mask elements.
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
by computed value

Browser support

First browser version supporting clip
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

clip-path

Property Baseline: widely availablesince July 2023 Modern CSS: Clip path boxes

MDN The clip-path CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the region are shown, while those outside are hidden.

Live preview Example from MDN
section {
  align-items: flex-start;
}

.example-container {
  text-align: left;
  padding: 20px;
}

#example-element {
  float: left;
  width: 150px;
  margin: 20px;
}

Syntax

<clip-source> | [ <basic-shape> || <geometry-box> ] | none

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
none
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
as specified, but with <url> values made absolute
Canonical order
per grammar
Animation type
by computed value

Browser support

First browser version supporting clip-path
Chrome 55
Edge 79
Firefox 3.5
Safari 9.1
Chrome Android 55
Safari iOS 9.3

First version with support, from MDN browser-compat-data.

clip-rule

Property Baseline: widely availablesince July 2022

MDN The clip-rule CSS property determines, when parts of the path overlap other parts, which pixels in a mask's box are inside the clipping shape defined by a clip path and which are outside.

Live preview Example from MDN
body {
  display: flex;
  gap: 20px;
}
svg {
  width: 110px;
  height: 110px;
}

#star1 path {
  clip-rule: evenodd;
}

#star2 path {
  clip-rule: nonzero;
}

#star3 path {
  fill: none;
  stroke: black;
  stroke-width: 1;
}

Syntax

nonzero | evenodd

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
nonzero
Applies to
Applies to SVG graphics elements
Inherited
yes
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting clip-rule
Chrome ≤15
Edge 79
Firefox 3.5
Safari ≤5
Chrome Android 18
Safari iOS ≤4.2

First version with support, from MDN browser-compat-data.

mask

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask CSS shorthand property hides an element (partially or fully) by masking or clipping a specified area of the image. It is a shorthand for all the mask-* properties. The property accepts one or more comma-separated values, where each value corresponds to a <mask-layer>.

Live preview Example from MDN
img,
div {
  border: 20px dashed rebeccapurple;
  box-sizing: content-box;
  padding: 20px;
  height: 220px;
  width: 220px;
}

img {
  mask: repeating-radial-gradient(
      circle,
      transparent 0 5px,
      lightgreen 15px 20px
    )
    content-box border-box 0% 0% / 100px 100px repeat;
}

div {
  background: repeating-radial-gradient(
      circle,
      transparent 0 5px,
      lightgreen 15px 20px
    )
    content-box border-box 0% 0% / 100px 100px repeat;
}

Syntax

<mask-layer>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
see individual properties
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
see individual properties
Computed value
see individual properties
Canonical order
per grammar
Animation type
see individual properties
Longhands
mask-image, mask-position, mask-size, mask-repeat, mask-origin, mask-clip, mask-composite, mask-mode

Browser support

First browser version supporting mask
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-border

Property Limited availability Modern CSS: mask-border

MDN The mask-border CSS shorthand property lets you create a mask along the edge of an element's border.

Live preview Example from MDN
.masked {
  width: 200px;
  background-color: lavender;
  border: 18px solid salmon;
  padding: 10px;

  -webkit-mask-box-image: url("https://mdn.github.io/shared-assets/images/examples/mask-border-diamonds.png")
    30 fill /          /* slice */
    20px /             /* width */
    1px                /* outset */
    round;             /* repeat */

  mask-border:
    url("https://mdn.github.io/shared-assets/images/examples/mask-border-diamonds.png")
    30 fill /        /* slice */
    20px /           /* width */
    1px              /* outset */
    round;           /* repeat */
}

Syntax

<'mask-border-source'> || <'mask-border-slice'> [ / <'mask-border-width'>? [ / <'mask-border-outset'> ]? ]? || <'mask-border-repeat'> || <'mask-border-mode'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
See individual properties
Applies to
See individual properties
Inherited
no
Percentages
n/a
Computed value
See individual properties
Canonical order
per grammar
Animation type
See individual properties
Longhands
mask-border-source, mask-border-slice, mask-border-width, mask-border-outset, mask-border-repeat, mask-border-mode

Browser support

First browser version supporting mask-border
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-border-mode

Property Not in any browser yet

MDN The mask-border-mode CSS property specifies the blending mode used in a mask border.

Syntax

luminance | alpha

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
alpha
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

mask-border-outset

Property Limited availability Modern CSS: mask-border

MDN The mask-border-outset CSS property specifies the distance by which an element's mask border is set out from its border box.

Syntax

<'border-image-outset'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
0
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
all <length>s made absolute, otherwise as specified
Canonical order
per grammar
Animation type
by computed value

Browser support

First browser version supporting mask-border-outset
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-border-repeat

Property Limited availability Modern CSS: mask-border

MDN The mask-border-repeat CSS property specifies how the images for the sides and the middle part of the mask border image are scaled and tiled.

Syntax

<'border-image-repeat'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
stretch
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-border-repeat
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-border-slice

Property Limited availability Modern CSS: mask-border

MDN The mask-border-slice CSS property divides the image set by mask-border-source into regions. These regions are used to form the components of an element's mask border.

Syntax

<'border-image-slice'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
0
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
refer to size of the mask border image
Computed value
as specified
Canonical order
per grammar
Animation type
by computed value

Browser support

First browser version supporting mask-border-slice
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-border-source

Property Limited availability Modern CSS: mask-border

MDN The mask-border-source CSS property sets the source image used to create an element's mask border.

Syntax

<'border-image-source'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
none
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
they keyword none or the computed <image>
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-border-source
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-border-width

Property Limited availability Modern CSS: mask-border

MDN The mask-border-width CSS property sets the width of an element's mask border.

Syntax

<'border-image-width'>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
relative to width/height of the mask border image area
Computed value
all <length>s made absolute, otherwise as specified
Canonical order
per grammar
Animation type
by computed value

Browser support

First browser version supporting mask-border-width
Chrome 1
Edge 79
Firefox No
Safari 17.2
Chrome Android 18
Safari iOS 17.2

First version with support, from MDN browser-compat-data.

mask-clip

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-clip CSS property determines the area which is affected by a mask. The painted content of an element must be restricted to this area.

Live preview Example from MDN
div {
  width: 100px;
  height: 100px;
  background-color: #8cffa0;
  margin: 10px;
  border: 20px solid #8ca0ff;
  padding: 20px;
  mask-image: url("https://mdn.github.io/shared-assets/images/examples/mdn.svg");
  mask-size: 100% 100%;
}
.content-box {
  mask-clip: content-box;
}
.border-box {
  mask-clip: border-box;
}
.padding-box {
  mask-clip: padding-box;
}
div::before {
  content: attr(class);
  position: relative;
  top: -10px;
}

body {
  display: flex;
  flex-flow: row wrap;
}

Syntax

[ <coord-box> | no-clip ]#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
border-box
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item the keyword as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-clip
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-composite

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-composite CSS property represents a compositing operation used on the current mask layer with the mask layers below it.

Live preview Example from MDN
div {
  width: 100px;
  height: 100px;
  background-color: red;

  mask-image:
    url("https://mdn.github.io/shared-assets/images/examples/mdn.svg"),
    url("https://mdn.github.io/shared-assets/images/examples/mask-star.svg");
  mask-size: 100% 100%;

  mask-composite: subtract;
}

Syntax

<compositing-operator>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
add
Applies to
All elements. In SVG, it applies to container elements without the defs element and all graphics elements
Inherited
no
Percentages
n/a
Computed value
list, each item the keyword as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-composite
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-image

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-image CSS property sets the image that is used as the mask layer for an element, hiding sections of the element on which the masking image is set based on the alpha channel of the mask image and, depending on the mask-mode property value, the luminance of the mask image's colors.

Live preview Example from MDN
img {
  mask-image: radial-gradient(black 50%, transparent 60%);
}

Syntax

<mask-reference>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
none
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item the keyword none, a computed <image>, or a computed <url>
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-image
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-mode

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-mode CSS property is set on the element being masked. It sets whether the mask reference defined by the mask-image is treated as a luminance or alpha mask.

Live preview Example from MDN
div {
  background: blue linear-gradient(red, blue);
  mask-image: url("https://mdn.github.io/shared-assets/images/examples/mdn.svg");
}

.alpha {
  mask-mode: alpha;
}

.luminance {
  mask-mode: luminance;
}

.matchSource {
  mask-mode: match-source;
}

div {
  width: 227px;
  height: 200px;
  float: left;
  text-align: center;
  line-height: 65px;
  color: white;
  text-shadow: 1px 1px 2px black;
  font-family: sans-serif;
}

Syntax

<masking-mode>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
match-source
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item the keyword as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-mode
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-origin

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-origin CSS property sets the origin of a mask. This property determines the mask positioning area: the area within which a mask image is positioned. HTML elements can have masks contained within their content border box, padding box, or content box, whereas SVG elements (which don't have the associated CSS layout boxes) can have masks contained inside their fill, stroke, or view box. For elements rendered as multiple boxes, such as a <span> of text that spans more than one line, the mask-origin property specifies which boxes the box-decoration-break property operates on to determine the mask positioning area.

Live preview Example from MDN
div {
  width: 100px;
  height: 100px;
  margin: 10px;
  border: 10px solid blue;
  background-color: #8cffa0;
  padding: 10px;
  mask-image: url("https://mdn.github.io/shared-assets/images/examples/mask-star.svg");
}
section {
  border: 1px solid black;
}

.content div {
  mask-origin: content-box;
}

.padding div {
  mask-origin: padding-box;
}

.border div {
  mask-origin: border-box;
}

.comparison div {
  mask-image: none;
}

section::before {
  content: attr(class);
  display: block;
  text-align: center;
}

body {
  display: flex;
  flex-flow: row wrap;
  gap: 10px;
}

Syntax

<coord-box>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
border-box
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item the keyword as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-origin
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-position

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-position CSS property sets the initial position, relative to the mask position layer set by mask-origin, for each defined mask image.

Live preview Example from MDN
section {
  border: 1px solid black;
  width: 250px;
  height: 250px;
}

div {
  width: 250px;
  height: 250px;
  margin-bottom: 10px;
  background: blue linear-gradient(red, blue);

  mask-image: url("https://developer.mozilla.org/shared-assets/images/examples/mask-star.svg");
  mask-repeat: no-repeat;
  mask-position: top right;
}

Syntax

<position>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
0% 0%
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
refer to size of mask painting area minus size of mask layer image; see text background-position [CSS3BG]
Computed value
list, each item consists of two keywords representing the origin and two offsets from that origin, each given as an absolute length (if given a <length>), otherwise as a percentage.
Canonical order
per grammar
Animation type
repeatable list

Browser support

First browser version supporting mask-position
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-repeat

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-repeat CSS property sets how mask images are repeated. A mask image can be repeated along the horizontal axis, the vertical axis, both axes, or not repeated at all.

Live preview Example from MDN
div {
  width: 250px;
  height: 250px;
  background-image: linear-gradient(red, blue);

  mask-image: url("https://developer.mozilla.org/shared-assets/images/examples/mask-star.svg");
  mask-size: 100px 100px;

  mask-repeat: round space;
}

Syntax

<repeat-style>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
repeat
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item a pair of keywords, one per dimension
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-repeat
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-size

Property Baseline: widely availablesince June 2026 Modern CSS: Masks

MDN The mask-size CSS property specifies the sizes of specified mask images. Mask image sizes can be fully or partially constrained to preserve their intrinsic aspect ratios.

Live preview Example from MDN
div {
  width: 200px;
  height: 400px;
  background: blue linear-gradient(red, blue);
  mask-image: url("https://developer.mozilla.org/shared-assets/images/examples/mdn.svg");
}

.width {
  mask-size: 50%;
}

.height {
  mask-size: auto 50%;
}

body {
  display: flex;
  gap: 20px;
}

Syntax

<bg-size>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
All elements. In SVG, it applies to container elements excluding the defs element, all graphics elements and the use element
Inherited
no
Percentages
n/a
Computed value
list, each item as specified, but with lengths made absolute
Canonical order
per grammar
Animation type
repeatable list

Browser support

First browser version supporting mask-size
Chrome 120
Edge 120
Firefox 53
Safari 15.4
Chrome Android 120
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

mask-type

Property Baseline: widely availablesince July 2022

MDN The mask-type CSS property applies to the SVG mask element. It defines whether to use the luminance (brightness) or alpha (transparency) content of the mask. This property may be overridden by the mask-mode property. The mask-type property has no effect on image or gradient masks.

Live preview Example from MDN
mask#alphaMask {
  mask-type: alpha;
}

mask#luminanceMask {
  mask-type: luminance;
}

img.alphaMaskType {
  mask-image: url("#alphaMask");
}

img.luminanceMaskType {
  mask-image: url("#luminanceMask");
}

Syntax

luminance | alpha

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
luminance
Applies to
mask elements
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting mask-type
Chrome 24
Edge 79
Firefox 35
Safari 7
Chrome Android 25
Safari iOS 7

First version with support, from MDN browser-compat-data.