— by Eva


Image masks in CSS work similarly to setting a background image but allow you to control which parts of an element are visible based on transparency. With the mask-image property, you can overlay a mask that dictates visibility by adjusting opacity levels—similar to placing a stencil over the image. The mask can range from simple gradients to detailed images, where more opaque areas remain visible, and transparent areas reveal what’s behind the element. Additional properties like mask-repeat, mask-position, and mask-size let you fine-tune the mask placement and behavior, offering a versatile way to create unique visual effects.

Session CodePen

See this Pen on CodePen.

See this Pen on CodePen.

Browser Support