Can SVG markup in HTML5 skip self-closing tags?
From the question Do I need a / "at the end of an <img> or <br> tag, etc.? I found out that self-closing tags, such as <br /> and <img /> , are completely optional in HTML5 and can simply be written like <br> and <img> .
But is this also true for SVG elements embedded in HTML5? For example, is it possible to write <circle> instead of the <circle /> <circle> ?
<svg viewBox="0 0 1000 1000"> <circle cx="500" cy="500" r="500" /> </svg> If allowed, is this generally good or bad practice?
Below are some rules that I found in W3 SVG and MathML elements in HTML documentation
- SVG and MathML elements whose start tags have a single "/" before the closing ">" are designated as self-closing.
- SVG and MathML elements must either have an start tag, or an end tag, or an start tag that is marked as self-closing, in which case they should not have an end tag.
- SVG and MathML elements whose start tag is marked as self-closing has no content.
- The contents of an SVG or MathML element whose beginning is not marked as self-closing are any elements, character data, comments, and CDATA sections that it contains, with the restriction that the character data contained in it must be normal character data.
I think that the second point applies the elements of svg , to have an explicit closing tag or self-closing tag.