Is there a way — preferably without using JavaScript — to put some HTML content into an SVG foreignObjectform so that the SVG form automatically resizes (or scales) to fit its contents?
those. something very vague, like this pseudo-code example, but valid and functional in the way I described:
<?xml version="1.0" standalone="yes"?>
<svg xmlns = "http://www.w3.org/2000/svg">
<rect x="10" y="10" width="SCALE_TO_FIT_CONTENTS" height="SCALE_TO_FIT_CONTENTS" fill="gray">
<foreignobject width="100%" height="100%">
<body xmlns="http://www.w3.org/1999/xhtml">
<div>Some HTML text</div>
</body>
</foreignobject>
</rect>
</svg>
source
share