CSS Portal

CSS mask-type Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The mask-type property controls how the browser interprets the visual information in a mask when deciding which parts of the element should be visible. Instead of changing layout or geometry, it affects the translation from the mask’s pixel data (colors, luminance, alpha) into an opacity map that is applied to the element during painting. Because different mask sources (for example raster images, vector shapes, or SVG graphic content) carry different kinds of information, the interpretation chosen by mask-type changes whether transparent/opaque areas come from an explicit alpha channel, from the brightness of pixels, or from the painted coverage of vector content - and that, in turn, affects edge softness, feathering, and the visual blending with what’s behind the element.

When you use mask resources specified by properties such as mask-image, or when multiple mask layers are combined, the role of mask-type becomes visible in how distinct mask sources are composed together. It determines whether a mask source contributes directly as an alpha mask or whether its luminance values are first converted to alpha-like coverage. That interpretation also influences how subsequent mask compositing operations (for example those governed by mask-composite) are resolved, because those compositing operations act on the alpha/coverage produced by each mask layer rather than on the raw color channels.

The choice set by mask-type also interacts with other rendering behaviors. It affects antialiasing at mask edges and how semi‑transparent pixels are treated - for instance, whether a soft gradient in the mask is treated as a smooth fade or whether transparent pixels are taken strictly as holes. It can change how filters and blending applied to mask content influence the final clip-like result, and it may produce different results for the same source image when used with SVG masks versus CSS image masks. Note that these effects are strictly visual: the property does not change layout, hit testing, or the element’s box model, though the visual opacity it produces can alter perceived hit areas in some user-agent behaviors.

For practical use, consider what information your mask source actually contains and how you want it interpreted: vector shapes and graphics that rely on painted coverage are commonly intended to be treated as graphic coverage, while photographic or painted textures may be intended to supply an alpha-like transparency. Also bear in mind that different interpretations can have performance implications on certain rendering paths; keeping mask content simple and matching the interpretation to the source content usually yields the most predictable and performant results. If you need a different kind of clipping rather than a painted softness or fade, you may find alternatives such as clip-path more appropriate for strict geometric clipping.

Definition

Initial value
luminance
Applies to
<mask> elements
Inherited
no
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.maskType

Syntax

mask-type: none | luminance | alpha;

Values

  • none The element is not treated as a mask. Essentially, masking is disabled.
  • luminance The mask is interpreted based on the brightness (luminance) of the mask image. Brighter areas are more opaque, darker areas are more transparent.
  • alphaThe mask is interpreted based on the alpha channel of the mask image. Fully opaque areas in the mask keep the element visible, while fully transparent areas hide it.

Example

<body>
<div class='container'>
<div class='card luminance'>
<div class='visual' aria-hidden='true'></div>
<div class='label'>mask-type: luminance</div>
</div>

<div class='card alpha'>
<div class='visual' aria-hidden='true'></div>
<div class='label'>mask-type: alpha</div>
</div>
</div>
</body>
:root {
  --mask-svg: data:image/svg+xml;utf8,;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  color: #fff;
}

.container {
  display: flex;
  gap: 28px;
  align-items: center;
}

.card {
  width: 240px;
  padding: 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.visual {
  width: 180px;
  height: 110px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff7a18 0%, #af002d 50%, #319197 100%);
  -webkit-mask-image: url(data:image/svg+xml;utf8,);
  mask-image: url(data:image/svg+xml;utf8,);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.luminance .visual {
  -webkit-mask-type: luminance;
  mask-type: luminance;
}

.alpha .visual {
  -webkit-mask-type: alpha;
  mask-type: alpha;
}

.label {
  font-size: 13px;
  opacity: 0.9;
}

Browser Support

The following information will show you the current browser support for the CSS mask-type 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
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!