oligofren
oligofren

Reputation: 22943

Valid locations for namespace declarations in html

I want to centralise the xmlns:xlink declaration in my html documents to avoid repeating them when using svg <use> tags with xref attributes.

Instead of

<svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 125">
  <use class="ic-3" xlink:href="#ic" x="0" y="0" />
</svg>

I will only need to write

<svg viewBox="0 0 100 125">
  <use class="ic-3" xlink:href="#ic" x="0" y="0" />
</svg>

The problem is that I that I failed in finding a good source for which locations/nodes in the html tree are valid for placing these namespace declarations. I understand that svg nodes are suitable and this W3 Fools article also mentions the document root as valid for XML documents, which I assumed. But is any parent node a valid location for a namespace declaration? Say, can I just put it in a parent div or the body tag? Not asking for best practice, just the legality according to xml.

Upvotes: 0

Views: 42

Answers (1)

Robert Longson
Robert Longson

Reputation: 124109

html does not support namespace declarations in markup so you can just delete them all.

Upvotes: 1

Related Questions