I am looking to visually crop my element using an SVG shape that is defined within the same HTML file (inline SVG).
Using clip-path
works perfectly:
div {
width: 200px;
height: 200px;
background-color: red;
clip-path: url("#c");
}
<div>
<svg>
<defs>
<clippath id="c">
<circle cx="100" cy="100" r="50" />
</clippath>
</defs>
</svg>
</div>
However, when using a mask, Chrome does not apply any masking effect even though it works fine in Firefox:
div {
width: 200px;
height: 200px;
background-color: red;
mask: url("#m");
}
<div>
<svg>
<defs>
<mask id="m">
<circle cx="100" cy="100" r="50" fill="white" />
</mask>
</defs>
</svg>
</div>
After researching (example), it appears that Chrome expects the mask to reference an entire image rather than a definition. Is there a way to refer to an entire image if it's been inlined? Or are there other methods I can try to apply a mask from an inline element?