Fix an SVG mask that hides an opaque black shape

Compare alpha and luminance masks with the same four swatches.

Asset preparation2 min read

An opaque black shape can make the artwork disappear when you use it as an SVG mask. The default luminance mode uses the mask's brightness and opacity together. Set mask-type="alpha" if the shape's opacity alone should determine what shows through.

Run the same swatches through both modes

Open the editable SVG. Both rows use the same white, gray, black, and transparent swatches to mask the same yellow strip. The checkerboard shows where the strip is hidden.

Luminance on top shows bright yellow in the white swatch, dim yellow in gray, and checkerboard in black and transparent. Alpha below shows full yellow for all three opaque swatches and checkerboard for the transparent one.

Mask swatchLuminanceAlpha
Opaque whiteFully visibleFully visible
Opaque grayPartly visibleFully visible
Opaque blackHiddenFully visible
Fully transparentHiddenHidden

Set the mode on the mask

Save this snippet as an SVG. With alpha, the yellow circle appears. Change only the mask type to luminance and it disappears.

svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
  <defs>
    <mask id="shape" mask-type="alpha">
      <circle cx="32" cy="32" r="24" fill="black"/>
    </mask>
  </defs>
  <rect width="64" height="64" fill="#ffca55" mask="url(#shape)"/>
</svg>

Keep luminance if gray in the existing mask is supposed to produce a fade. Changing it to alpha makes opaque gray reveal the artwork fully. If changing mask-type has no effect on the website, inspect the masked element for a CSS mask-mode override and reopen the exported SVG by itself. W3C mask type and overrides.

Image tools
All guides
Fix an SVG mask that hides an opaque black shape | Formatry Media — Formatry