The mask attribute is a presentation attribute mainly used to bind a given <mask> element with the element the attribute belongs to.

Note: As a presentation attribute mask can be used as a CSS property.

You can use this attribute with the following SVG elements:


<svg viewBox="0 0 200 100" xmlns="">
  <mask id="myMask" maskContentUnits="objectBoundingBox">
    <rect fill="white" x="0" y="0" width="100%" height="100%" />
      points="0.5,0.2 0.68,0.74 0.21,0.41 0.79,0.41 0.32,0.74" />

  Punch a hole in a shape of a star inside the red circle,
  revealing the yellow circle underneath
  <circle cx="50" cy="50" r="20" fill="yellow" />
  <circle cx="50" cy="50" r="45" fill="red" mask="url(#myMask)" />

Since SVG2, the mask attribute is defined as a CSS property and is a shorthand for many other properties: mask-image, mask-mode, mask-repeat, mask-position, mask-clip, mask-origin, mask-size, and mask-composite.

Usage notes

Value See the CSS property mask
Default value none
Animatable Yes


CSS Masking Module Level 1
# the-mask

Browser compatibility

BCD tables only load in the browser