I really know nothing about SVG but I need to use it for an app I'm building. So some help getting started would be really appreciated.
I want to nest a div
inside of an SVG shape, which I would imagine would work like this:
<svg width="250" height="250" viewBox="0 0 250 250">
<rect x="0" y="0" width="100" height="100" fill="red">
<foreignObject width="100%" height="100%">
<div>TEST</div>
</foreignObject>
</rect>
</svg>
But as you see, it only renders the rect
element.
Even if I try only using text
, then it still doesn't appear, as you can see:
<svg width="250" height="250" viewBox="0 0 250 250">
<rect x="0" y="0" width="100" height="100" fill="red">
<text x="50%" y="50%">TEST 2</text>
</rect>
</svg>
So what am I doing wrong here? Why don't SVG elements appear when nested inside of other SVG elements? And how can I make them do so?
Thank you