The mask
property in CSS allows you to control which parts of an element are visible. It uses a mask image or gradient to hide or reveal parts of an element, similar to how a stencil would work.
The following examples demonstrate different types of CSS masking:
This image is masked using a circular mask. The radial-gradient
is used to create a circular mask that hides the outer parts of the image, leaving only the center visible.
This image is masked using a heart-shaped mask. The mask is defined using an SVG path, which creates a heart-shaped hole in the image.
This image is masked using an elliptical mask. The radial-gradient
is used to create an elliptical shape that hides parts of the image outside the ellipse.