mask

mask 属性は、主に指定された <mask> 要素とその属性が属する要素を結びつけるために使用されるプレゼンテーション属性です。

メモ: プレゼンテーション属性なので、 mask は CSS プロパティとして使用できます。

この属性は以下の SVG 要素で使用することができます。

html
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
  <mask id="myMask" maskContentUnits="objectBoundingBox">
    <rect fill="white" x="0" y="0" width="100%" height="100%" />
    <polygon
      fill="black"
      points="0.5,0.2 0.68,0.74 0.21,0.41 0.79,0.41 0.32,0.74" />
  </mask>

  <!--
  赤丸の中に星形の穴を開け、
  丸の下の黄色を見せます。
  -->
  <circle cx="50" cy="50" r="20" fill="yellow" />
  <circle cx="50" cy="50" r="45" fill="red" mask="url(#myMask)" />
</svg>

SVG2 以降、mask 属性は CSS プロパティとして定義されており、多くの他のプロパティ (mask-image, mask-mode, mask-repeat, mask-position, mask-clip, mask-origin, mask-size, mask-composite) の一括指定となっています。

使用上のメモ

CSS プロパティ mask を参照
既定値 none
アニメーション

仕様書

Specification
CSS Masking Module Level 1
# the-mask

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
mask

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.