SVG Clipping vs. Masking
I recently came across clipping and masking in SVG. I noticed that the <mask> element includes every feature of the <clipPath> element.
In addition, <clipPath> has many disadvantages:
- lower browser compatibility
- no transparency allowed
- no structural, gradient or image elements allowed
Because of this I wonder what the <clipPath> element is for:
The <mask> element is much more powerful!
That is my code:
<svg viewBox="0 0 100 100" width="100" height="100">
<defs>
<clipPath id="clip">
<rect x="0" y="0" width="50" height="50"/>
</clipPath>
</defs>
<circle cx="50" cy="50" r="50" fill="grey" clip-path="url(#clip)"/>
</svg>
Finally, my questions:
- Should I use
<mask>instead of<clipPath>in my code snippet? - Is there any situation when
<clipPath>is more suitable than<mask>?