CSS Mask Generator
Generate mask-image CSS with live preview. Fade edges, create radial vignettes and spotlight effects — with vendor prefixes and Tailwind output included.
How to use
Choose a mask preset
Select from Fade Top, Fade Bottom, Fade Left, Fade Right, Radial Fade or Spotlight. Each preset generates a different gradient direction or shape for the mask.
Adjust strength and size
Mask Strength controls how transparent the faded end is — 100% is fully transparent, 0% is no effect. Fade Size controls how far the gradient extends across the element.
Position the focal point
For Radial Fade and Spotlight presets, use Position X and Y sliders to move the centre of the effect. Toggle Invert to flip which areas are visible and which are masked.
Copy and paste the code
Copy the CSS tab for plain CSS with vendor prefixes, the HTML tab for a complete self-contained snippet, or the Tailwind tab for JIT arbitrary value usage in Tailwind projects.
What CSS masking is used for
Scroll fade — read more
Fade the bottom of long text to hint that more content exists below. A linear-gradient mask creates a smooth transition to the background without JavaScript.
Image edge blending
Blend an image seamlessly into a coloured background or another image using a directional fade mask — ideal for hero sections and full-bleed photography.
Spotlight effects
Highlight a focal area — a product, a face, a UI element — by masking the surrounding region with a radial gradient that darkens the edges.
Section transitions
Create smooth visual transitions between stacked page sections without SVG dividers. A fade-bottom mask on the upper section blends into the next section's background.
Text reveal animations
Combine mask-image with CSS animations to reveal text as the mask gradient transitions from fully transparent to fully opaque — no JavaScript required.
Vignette overlays
Apply a radial-gradient mask centred on an image to darken the corners and draw the eye to the middle — a classic photography vignette technique in pure CSS.
How CSS masking works
What is CSS masking?
mask-image applies an image or gradient as a pixel-level visibility mask. The alpha channel controls opacity — black (alpha 1) is fully visible, transparent (alpha 0) is fully hidden. The mask is composited with the element before it is painted to the screen, enabling smooth gradients between visible and hidden states.
Mask vs clip-path
clip-path clips to a hard geometric boundary with no intermediate values — pixels are either fully in or fully out. mask-image uses per-pixel alpha values from a gradient or image, enabling smooth fades. Use clip-path for crisp shapes; use mask-image for gradual transitions, vignettes and artistic blending effects.
Browser support
mask-image with -webkit- prefix is supported in Chrome 4+, Safari 3.1+, Edge 79+ and Opera. The unprefixed mask-image is supported in Firefox 53+ and all modern Chromium browsers (Chrome 120+). Always include both -webkit-mask-image and mask-image. Global support exceeds 97% of browsers in use today.
Performance
CSS masks are applied during the compositing phase — the same GPU-accelerated stage as opacity and transform. Masks do not trigger layout or paint recalculations when animated. For animated masks, add will-change: mask to promote the element to its own compositing layer, ensuring smooth 60fps transitions without jank.
Related tools
Frequently asked questions
Quick answers about this free online tool.
