Can SVG markup in HTML5 omit self
From the question Do I need a "/" at the end of an <img> or <br> tag, etc.? I learned that self-closing tags such as <br />
and <img />
are entirely optional in HTML5 and may simply be written as <br>
and <img>
.
But is that also true for SVG elements placed inline with HTML5? For example, can the <circle />
tag be written instead as <circle>
?
<svg viewBox="0 0 1000 1000">
<circle cx="500" cy="500" r="500" />
</svg>
If it is allowed, is it generally good or bad practice?
Below are some rules I found out in the W3 SVG and MathML elements in HTML documents documentation
I think the second point enforces svg
elements to have a explicit closing tag or a self-closing tag.
上一篇: 如何使用结束标签写入空元素的浏览器?
下一篇: HTML5中的SVG标记可以省略自己