SVG tags (although can be included within HTML) are XML tags, notHTML tags.
to create SVG elements with JavaScript, canโt usecreateElement(), must use createElementNS(), which takes an XML namespace string (for SVG, it's "http://www.w3.org/2000/svg") as its first argument.
<!-- โญ๏ธ
`width="0" height="0"` or
`display="none"`
prevent SVG from being rendered
-->
<svg width="0" height="0">
<!-- โญ๏ธ definitions to be used later -->
<defs>
<!-- โญ๏ธ `g` for group, much like `div` in HTML -->
<g id="xxx">
<path d="">
<path d="">
</g>
</defs>
<!-- โญ๏ธ SVG will NOT draw `symbol`, it's just a definition -->
<symbol id="twitter" viewBox="0 0 100 100">
<title>@CoolCompany on Twitter</title>
<path d="...">
</symbol>
<symbol id="codepen" viewBox="0 0 200 175">
<title>See Our CodePen Profile</title>
<path d="...">
<path d="...">
</symbol>
</svg>
<!-- โญ๏ธ this will draw an icon here. -->
<svg class="icon" viewBox="0 0 100 100">
<!-- `title` is for screen reader -->
<title>@CoolCompany on Twitter</title>
<!-- โญ๏ธ use icon with ID "twitter" in definitions -->
<use xlink:href="#twitter" />
</svg>
.icon {/* โญ๏ธ match font-size */width:1em;height:1em;/* โญ๏ธ match text color */fill:currentColor; }