Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

mask-type — interpreting an SVG mask

mask-type selects how SVG mask content is interpreted: luminance uses luminance and transparency, while alpha uses transparency alone.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

mask-type: luminance | alpha;

mask-type applies to SVG mask elements, not the masked element. Its initial value is luminance; it is not inherited, and animation is discrete.

luminance multiplies luminance by alpha: opaque black hides and white reveals. alpha ignores color: opaque black and white reveal equally. Transparent areas hide in both modes.

With mask-mode: match-source on the masked element, the referenced mask’s mask-type applies. Explicit mask-mode: alpha or mask-mode: luminance overrides that choice. match-source is not a mask-type value. Setting mask-type alone does not assign a mask; the example uses mask with a url(...) reference.

Examples

<!doctype html>
<meta charset="utf-8">
<title>mask-type</title>
<style>
  #luma { mask-type: luminance; }
  #alpha { mask-type: alpha; }
  .target { mask-mode: match-source; }
</style>
<svg xmlns="http://www.w3.org/2000/svg" width="220" height="70" viewBox="0 0 220 70">
  <defs>
    <mask id="luma" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="60">
      <rect width="50" height="60" fill="black"/>
      <rect x="50" width="50" height="60" fill="white"/>
    </mask>
    <mask id="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="60">
      <rect width="50" height="60" fill="black"/>
      <rect x="50" width="50" height="60" fill="white"/>
    </mask>
  </defs>
  <rect width="220" height="70" fill="white"/>
  <rect class="target" width="100" height="60" fill="blue" mask="url(#luma)"/>
  <g transform="translate(120 0)">
    <rect class="target" width="100" height="60" fill="blue" mask="url(#alpha)"/>
  </g>
</svg>

Result

Expected: on white, the left target shows only its right blue half; the right target is entirely blue.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources