freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #15 of 50

mask · alpha + image masking

PrismaVSJank the Janitor
Prisma saysmask hides parts of an element using an image or gradient’s alpha/luminance.

mask-image (often a gradient) makes parts of an element transparent based on the mask's alpha — great for fade-out edges or punching an image into a shape. Where clip-path cuts a hard edge, masks give soft, gradient-based transparency.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleFade the bottom of an image to transparent with a linear-gradient mask.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>img{width:240px;-webkit-mask-image:linear-gradient(#000 60%,transparent);mask-image:linear-gradient(#000 60%,transparent)}</style></head><body style="background:#06040d;padding:20px"><img src="https://via.placeholder.com/240x160" alt=""></body></html>
▶ Open the interactive comic issue
‹ Clip-Path · Cropping With ShapesShapes · Shape-Outside · Text Wrapping ›