Try using HTML markup in an SVG file

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 22:41:29 -07:00
parent 1299c2cdaf
commit 1d9f5325c5
2 changed files with 22 additions and 0 deletions

View File

@ -22,6 +22,21 @@
<rect id="background"/>
<foreignObject width="100%" height="100%">
<!--
In the context of SVG embedded in an HTML document, the XHTML
namespace could be omitted, but it is mandatory in the
context of an SVG document
-->
<div style="background-color: orange" xmlns="http://www.w3.org/1999/xhtml">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis mollis
mi ut ultricies. Nullam magna ipsum, porta vel dui convallis, rutrum
imperdiet eros. Aliquam erat volutpat.
<img src="test.svg" width="10" height="10"/>
</div>
</foreignObject>
<g class="gameboard">
<g id="firing-arcs">
<g id="shapes"/>
@ -29,5 +44,6 @@
</g>
<g class="grid"/>
</g>
<script href="map.js" data-cols="33" data-rows="25"></script>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

6
public/test.svg Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg viewBox="-5 -5 10 10" xmlns="http://www.w3.org/2000/svg">
<circle r="5" fill="purple"/>
</svg>

After

Width:  |  Height:  |  Size: 241 B