1

Having tested, everything works fine when I remove the closing slashes, however I'm wondering if this will cause a problem on other devices and browsers?

Are the closing slashes necessary on these elements?

<svg><use xlink:href="#exercise" /></svg>
<path d="..." />

Into

<svg><use xlink:href="#exercise"></svg>
<path d="...">
ditto
  • 5,917
  • 10
  • 51
  • 88

2 Answers2

1

Closing tags on path are needed or they will nest. I think it's safe to omit the slash on a use element though.

Compare these two:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4557 1024"><path d="M768 1024l-768-768v-256h128l640 640v-640h256v1024h-256z"><path d="M1177.6 1024v-1024h1024v256h-768v128h768v256h-768v128h768v256h-1024z"><path d="M2355.2 1024v-256h768v-128h-768v-640h1024v256h-768v128h768v640h-1024z"><path d="M3532.8 1024v-1024h256v384h512v-384h256v1024h-256v-384h-512v384h-256z"></svg>
    
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4557 1024"><path d="M768 1024l-768-768v-256h128l640 640v-640h256v1024h-256z"/><path d="M1177.6 1024v-1024h1024v256h-768v128h768v256h-768v128h768v256h-1024z"/><path d="M2355.2 1024v-256h768v-128h-768v-640h1024v256h-768v128h768v640h-1024z"/><path d="M3532.8 1024v-1024h256v384h512v-384h256v1024h-256v-384h-512v384h-256z"/></svg>
ditto
  • 5,917
  • 10
  • 51
  • 88
1

The closing slashes are still needed. The HTML5 spec defines the svg element to be embedded content and further states

The semantics of SVG elements are defined by the SVG specification

As laid out in the SVG spec the svg document is an XML grammar to which the rules for XML apply. Looking at the definitions covering the logical structure of the xml document the XML spec states, that

The end of every element that begins with a start-tag must be marked by an end-tag

If the element is empty, an empty-element tag may be used instead. This, however, still requires the closing slash.

altocumulus
  • 21,179
  • 13
  • 61
  • 84