Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. SVG
  3. Reference
  4. Attributes
  5. mask

mask

Baseline 2023
Newly available

Since December 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Themask attribute is a presentation attribute mainly used to bind a given<mask> element with the element the attribute belongs to.

Note:As a presentation attribute,mask also has a CSS property counterpart:mask. When both are specified, the CSS property takes priority.

You can use this attribute with the following SVG elements:

Example

html,body,svg {  height: 100%;}
html
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">  <mask 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>  <!--  Punch a hole in a shape of a star inside the red circle,  revealing the yellow circle underneath  -->  <circle cx="50" cy="50" r="20" fill="yellow" />  <circle cx="50" cy="50" r="45" fill="red" mask="url(#myMask)" /></svg>

Since SVG2, themask attribute is defined as a CSS property and is a shorthand for many other properties:mask-image,mask-mode,mask-repeat,mask-position,mask-clip,mask-origin,mask-size, andmask-composite.

Usage notes

ValueSee the CSS propertymask
Default valuenone
AnimatableYes

Specifications

Specification
CSS Masking Module Level 1
# the-mask

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp