CSS mask-image: Alpha Gradients, Vector Shapes & Cutout Masks

The Quick Answer

CSS mask-image applies an alpha transparency mask to any element. Unlike clip-path (which only produces sharp, binary polygon cutouts), mask-image supports soft, 8-bit alpha transparency gradients (e.g. mask-image: linear-gradient(to bottom, black 60%, transparent 100%)) and complex vector SVGs with translucent antialiased edges. Pair with -webkit-mask-image for 100% cross-browser rendering.

Interactive Demo Live Preview
mask-image Spotlight Reveal ALPHA MASK
COMPOSITED MASK BEAM
Radial Luminance Cutout Active

Step 1: mask-image vs clip-path: When to Use Which

Use clip-path when you need geometric cuts with hard, crisp vector edges (like triangles or polygons). Use mask-image when you require soft gradient fades, feathered vignette spotlights, or raster PNG cutouts with variable alpha transparency.

mask-vs-clip.css
/* clip-path: Hard geometric polygon */
.hard-cut {
  clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}

/* mask-image: Smooth 8-bit alpha gradient fade */
.soft-fade {
  -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 70%, transparent 100%);
}

Step 2: Radial Vignettes & Spotlight Reveals

Create elegant photographic spotlights using radial gradient masks. Setting the center to black (fully visible) and feathering to transparent produces a natural focus vignette.

radial-vignette.css
.spotlight-portrait {
  -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
  mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

Step 3: Vector SVG Masks: Complex Cutout Brand Shapes

Reference external or inline vector SVG graphics as the mask source. The shape of the vector graphic cuts through the HTML element, supporting intricate brand marks and organic blob contours.

svg-mask.css
.brand-masked-hero {
  -webkit-mask-image: url('brand-monogram.svg');
  mask-image: url('brand-monogram.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

Step 4: Compositing Multiple Masks with mask-composite

Combine multiple mask layers using mask-composite: add | subtract | intersect | exclude. This allows you to punch cutouts out of linear fades directly in CSS without opening Photoshop.

composite-masks.css
.complex-mask {
  mask-image: 
    linear-gradient(to bottom, black, transparent),
    radial-gradient(circle at top right, black 30%, transparent 70%);
  mask-composite: intersect; /* Only visible where both masks overlap */
}

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

Mask: Radial Spotlight Vignette ALPHA 8-BIT

1. CSS Image Mask & Alpha Gradient Generator

Explore in Image Mask Studio →

Create CSS mask-image rules — linear fades, radial reveals, vignettes, spotlights, and SVG cutouts with instant live code.

Data URI Mask (0.2 KB SVG)

2. SVG Data URIs in SVG to CSS Studio

Explore in SVG to CSS Studio →

Convert vector SVG mask cutouts into lightweight base64 data URIs for inline zero-HTTP request masks.

Ken Burns Pan + Alpha Mask 60 FPS GPU

3. Cinematic Motion in Ken Burns Studio

Explore in Ken Burns Studio →

Apply feathered alpha gradient masks to slow Ken Burns pan-and-zoom hero photography for seamless page blending.

Chaam
Chaam's Pro Tip

A trick I use in almost every project: don't fight specificity battles with !important. Leverage modern CSS cascade layers (@layer) and CSS variables as design tokens—it makes dark/light theme switching and responsive tuning effortless.

Why I Built the CSS Image Mask & Alpha Gradient Generator Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in CSS Image Mask & Alpha Gradient Generator ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

Why do I need to include -webkit-mask-image alongside mask-image?

While standard `mask-image` is widely supported, Safari, Chrome, and Edge still maintain legacy WebKit rendering pipeline paths for mask sizing and composite operations. Declaring both ensures 100% visual consistency.

In CSS mask-image, does black mean visible and white mean transparent?

By default (`mask-mode: alpha`), opacity is dictated by the alpha channel of the mask image (opaque = visible, transparent = hidden). If you switch to luminance mode (`mask-mode: luminance`), white is 100% visible and black is completely transparent.

Can mask-image be animated with CSS transitions?

Yes! You can smoothly animate `mask-position` and `mask-size` (such as expanding a radial spotlight on hover). Animating gradient color stops is also supported in modern Chromium and Safari.

Does mask-image hide elements from accessibility screen readers?

No. Visual masking only affects pixel transparency on screen. Screen readers continue to read text inside a masked container unless it is explicitly marked with `aria-hidden="true"`.

Can I apply mask-image to an HTML5

Yes! `mask-image` works identically on `