Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML in SVG as SVG
    text
    copied!<p>Recently started working with html in SVG. The code works fine FireFox but Chrome does not display the div content.</p> <p>Can you please help me sort this issue. Here is a sample code that should show div content as "MY DIV" and an Airport symbol.</p> <p>The code is saved as my_div.svg </p> <p>Thanks in advance.</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" viewport-fill="red"&gt; &lt;defs&gt; &lt;!-- My div --&gt; &lt;symbol id="my_div" viewBox="0 0 50 50" &gt; &lt;foreignObject x="0" y="0" width="50" height="50" fill="red"&gt; &lt;body xmlns="http://www.w3.org/1999/xhtml" style="background:none transparent;" width="50" height="50"&gt; &lt;div&gt;MY DIV&lt;/div&gt; &lt;/body&gt; &lt;/foreignObject&gt; &lt;/symbol&gt; &lt;!-- Airport Symbol --&gt; &lt;symbol id="airport" viewBox="0 0 10 10"&gt; &lt;path d="M 9.2,5 C 9.2,4.5 9.8,3.2 10,3 L 9,3 L 8,4 L 5.5,4 L 8,0 L 6,0 L 3,4 C 2,4 1,4.2 0.5,4.5 C 0,5 0,5 0.5,5.5 C 1,5.8 2,6 3,6 L 6,10 L 8,10 L 5.5,6 L 7.8,6 L 9,7 L 10,7 C 9.8,6.8 9.2,5.5 9.2,5 z "/&gt; &lt;/symbol&gt; &lt;/defs&gt; &lt;g fill="red" transform="scale(18)" &gt; &lt;g transform="translate(0, 0)"&gt; &lt;use xlink:href="#my_div" width="5" height="5"/&gt; &lt;/g&gt; &lt;g id="demo" transform="translate(0, 0)"&gt; &lt;use xlink:href="#airport" x="10" y="0" width="5" height="5"/&gt; &lt;/g&gt; &lt;/g&gt; &lt;/svg&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload