CSS mask Property
Description
The mask property controls which parts of an element are visible by using an image, gradient, or SVG as an alpha (or luminance) mask: the mask’s transparency determines pixel-level visibility of the element it’s applied to. Instead of trimming content to a hard-edged shape, a mask can create soft, feathered edges and partial transparency, allowing smooth transitions between visible and transparent areas. Because masks operate on the element’s rendered pixels, they affect the element’s final compositing rather than its document layout.
A mask is often used alongside decorative and compositing techniques - for example, you can mask an element that also uses a complex background to create shaped or faded backgrounds without altering the underlying layout or markup. See background-image for how decorative images can interact with masked content. Compared with vector clipping, masks provide richer visual control: clip-path produces crisp geometric boundaries, while mask can express graduations of transparency, soft glows, and non-rectangular fades.
Under the hood, masks are applied during the compositing stage, which means browsers may rasterize masked layers and this can affect rendering performance for complex or animated content. For visual effects that alter appearance rather than visibility you might instead consider filter, but masks remain the most direct way to create per-pixel visibility control. When using masks in production, plan for fallbacks for environments where masking is limited, and avoid relying on masks to convey critical information (such as hiding important text) because they can affect readability and accessibility if not designed carefully.
Definition
- Initial value
- See individual properties
- Applies to
- all elements; In SVG, it applies to container elements excluding the <defs> element and all graphics elements
- Inherited
- no
- Computed value
- See individual properties
- Animatable
- See individual properties
- JavaScript syntax
- object.style.mask
Syntax
mask: <mask-image> || <mask-mode> || <mask-repeat> || <mask-position> || <mask-clip> || <mask-origin> || <mask-composite> || <mask-size> || <mask-type>;
Values
- <mask-image>See mask-image CSS property for values.
- <mask-mode>See mask-mode CSS property for values.
- <mask-repeat> See mask-repeat CSS property for values.
- <mask-position>See mask-position CSS property for values.
- <mask-clip>See mask-clip CSS property for values.
- <mask-origin>See mask-origin CSS property for values.
- <mask-composite>See mask-composite CSS property for values.
- <mask-size>See mask-size CSS property for values.
- <mask-type>See mask-type CSS property for values.
Example
Browser Support
The following information will show you the current browser support for the CSS mask property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
