0

I pasted the following into the html:

<svg width="400px" height="300px" viewBox="0 0 400 300" xmlns="http://www.w3.org/2000/svg">
    <foreignObject width="100" height="50" requiredExtensions="http://www.w3.org/1999/xhtml">
        <body xmlns="http://www.w3.org/1999/xhtml">
            <p>Here is a paragraph that requires word wrap</p>
        </body>
    </foreignObject>
</svg>

However, it's represented as

<svg width="400px" height="300px" viewBox="0 0 400 300" xmlns="http://www.w3.org/2000/svg">
    <foreignobject width="100" height="50" requiredextensions="http://www.w3.org/1999/xhtml">
      <!-- XHTML content goes here -->      
        <p>Here is a paragraph that requires word wrap</p>  
    </foreignobject>
</svg>

in the DOM. Why is body removed?

Here, for example, body stays inside the DOM.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • 2
    I believe that [MDN](https://developer.mozilla.org/en/docs/Web/HTML/Element/body) has a great explanation - `There can be only one element in a document.`. – Mjh Jul 22 '16 at 14:18
  • "Because reasons", but basically there can only be one `` element in an HTML document. – Niet the Dark Absol Jul 22 '16 at 14:18
  • Because the `` tag is taken. Just like you would expect `

    ` to act as a paragraph, `

    ` acts like an HTML body tag, of which there can be only one in the document.
    – Emil S. Jørgensen Jul 22 '16 at 14:19
  • @NiettheDarkAbsol, as I understand it, `foreignObject` element allows for custom html, including `body` tag. The web page in the app I'm working on has many `body` elements inside `foreignobject` tags – Max Koretskyi Jul 22 '16 at 14:45
  • @Maximus if you include html in an svg document, then you could use multiple `body` tags, but øu haven an inline `svg` within `html`. – t.niese Jul 22 '16 at 14:51
  • @t.niese, how can I do that? I tried to include an `svg` document with tag, but then the content is rendered inside `#document` tag. This is not how I see the svg elements rendered inside the page I'm exploring – Max Koretskyi Jul 26 '16 at 13:40

0 Answers0