files/en-us/web/svg/reference/element/mask/index.md
The <mask> SVG element defines a mask for compositing the current object into the background. A mask is used/referenced using the {{SVGAttr("mask")}} property and CSS {{cssxref("mask-image")}} property.
{{svginfo}}
120%; Animatable: yes<mask>.
Value type: alpha | luminance; Default value: luminance; Animatable: yes<mask>.
Value type: userSpaceOnUse | objectBoundingBox; Default value: userSpaceOnUse; Animatable: yes<mask>.
Value type: userSpaceOnUse | objectBoundingBox; Default value: objectBoundingBox; Animatable: yes-10%; Animatable: yes-10%; Animatable: yes120%; Animatable: yesThis element implements the {{domxref("SVGMaskElement")}} interface.
html,
body,
svg {
height: 100%;
}
<svg viewBox="-10 -10 120 120">
<rect x="-10" y="-10" width="120" height="120" fill="blue" />
<mask id="myMask" mask-type="luminance">
<!-- Everything under a white pixel will be visible -->
<rect x="0" y="0" width="100" height="100" fill="white" />
<!-- Everything under a black pixel will be invisible -->
<path
d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z"
fill="black" />
</mask>
<polygon points="-10,110 110,110 110,-10" fill="orange" />
<!-- with this mask applied, we "punch" a heart shape hole into the circle -->
<circle cx="50" cy="50" r="50" fill="purple" mask="url(#myMask)" />
</svg>
{{EmbedLiveSample('Example', 100, 100)}}
{{Specifications}}
{{Compat}}