The mask-image property defines an image or gradient mask that controls which parts of an element stay visible — ideal for soft fades, custom silhouettes, and creative visual effects.
01
Alpha Mask
Hide by transparency.
02
url()
PNG or SVG masks.
03
Gradients
Soft fade effects.
04
none Default
Fully visible.
05
WebKit
Prefix for Safari.
06
Related
mask-size, mode.
Fundamentals
Introduction
The mask-image property in CSS allows you to define an image as a mask for an element. It can partially or fully hide parts of the element’s content based on the mask’s transparency.
Masks work by controlling the visibility of each pixel: a transparent mask pixel hides the corresponding part of the element, and an opaque mask pixel keeps it visible. This is especially useful for complex visual effects and shapes without extra SVG markup.
Definition and Usage
Apply mask-image when you want soft edges, image-based silhouettes, or gradient fades. Pair it with related properties like mask-size and mask-repeat to position and scale the mask.
💡
Beginner Tip
Start with a linear-gradient() mask for a simple top-to-bottom fade, then try url() with a PNG silhouette for shaped reveals.
Foundation
📝 Syntax
The syntax for the mask-image property allows URLs to images, CSS gradients, and the keyword none:
mask-image supports soft alpha fades from gradients and images. clip-path cuts hard geometric edges — choose based on the effect you need.
A11y
♿ Accessibility
Do not hide essential content — Masked-away text or controls may be invisible but still exist in the DOM.
Provide alt text for images used as visible content, even when masked decoratively.
Test contrast — Gradient fades can reduce readability if text sits over masked areas.
Check pointer events — Hidden mask areas may still receive clicks unless you adjust interaction.
Offer fallbacks — Ensure content remains usable when masking is unsupported.
Compare
mask-image vs clip-path
Feature
mask-image
clip-path
Edge type
Soft alpha fades from images and gradients
Hard geometric edges
Sources
PNG, SVG, CSS gradients
circle(), polygon(), inset(), SVG path
Best for
Silhouettes, vignettes, textured reveals
Avatars, triangles, precise shape cuts
Related props
mask-size, mask-repeat, mask-mode
Standalone shape property
🧠 How mask-image Works
1
You define a mask source
Choose a PNG, SVG, or CSS gradient with mask-image.
Mask source
2
Browser maps alpha values
Each mask pixel controls visibility of the matching element pixel.
Alpha mapping
3
Transparent areas hide content
Opaque mask pixels stay visible; transparent pixels reveal whatever is behind the element.
Compositing
=
🖼
Shaped or faded reveal
Your element appears through custom silhouettes, soft fades, or spotlight effects.
Compatibility
🖥 Browser Compatibility
The mask-image property is supported in most modern browsers, including Chrome, Firefox, Safari, and Edge. Include -webkit-mask-image for Safari, and test your target browser versions.
✓ Baseline · Modern browsers
Masking in modern browsers
Image and gradient masks work in all major browsers. Use the WebKit prefix for best Safari coverage.
95%Modern browser support
Google Chrome55+ · Desktop & Mobile
Full support
Mozilla Firefox54+ · Desktop & Mobile
Full support
Apple Safari9.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera42+ · Modern versions
Full support
mask-image property95% supported
Bottom line: Safe for modern projects. Pair mask-image with -webkit-mask-image and test PNG masks in Safari.
Wrap Up
🎉 Conclusion
The mask-image property is a powerful tool for creating visually stunning effects by manipulating element visibility with masks.
Whether you’re creating custom shapes, hiding parts of an image, or applying soft gradient fades, this property offers a flexible solution. Experiment with different masks and see how you can enhance your web designs with this technique.
Use url() PNG masks for custom silhouettes and logos
Try gradient masks for soft fades without extra image files
Include -webkit-mask-image alongside mask-image
Pair with mask-size and mask-repeat for proper positioning
Use clip-path when you need hard geometric edges instead
❌ Don’t
Hide essential text or controls with masks
Assume masked-away areas block pointer events by default
Forget WebKit prefixes when targeting Safari users
Skip fallbacks for critical visible content
Use masking when a simple border-radius or clip-path would suffice
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about mask-image
Use these points when applying image and gradient masks.
5
Core concepts
🖼01
Alpha mask
Controls visibility.
Purpose
⚙02
none Default
Fully visible.
Default
url03
Image masks
PNG silhouettes.
Values
grad04
Gradients
Soft fades.
Technique
web05
WebKit prefix
Safari support.
Compat
❓ Frequently Asked Questions
The mask-image property defines an image or gradient used as a mask. Transparent areas of the mask hide the corresponding parts of the element; opaque areas keep them visible.
The default value is none, meaning no mask is applied and the element is fully visible.
mask-image hard-cuts an element to a geometric shape. mask-image uses alpha or luminance from an image or gradient for softer, more complex visibility effects.
Yes. linear-gradient() and radial-gradient() are common mask values for fades, vignettes, and soft edges without extra image files.
Safari historically required the -webkit- prefix. Include both mask-image and -webkit-mask-image in production CSS for the widest support.