JSFiddle - React, Tailwind, and code Playground

by Jeremy Banks

HTML

<div id="container"></div>

JavaScript

var NS_SVG = "http://www.w3.org/2000/svg",
    NS_XLINK = "http://www.w3.org/1999/xlink",
    
    container = document.getElementById( "container" ),
    
    svg  = document.createElementNS( NS_SVG, "svg" ),
    a    = document.createElementNS( NS_SVG, "a" ),
    text = document.createElementNS( NS_SVG, "text" );

svg.setAttribute( "width", 200 );
svg.setAttribute( "height", 50 );
svg.style.border = "1px dashed gray";

a.setAttributeNS( NS_XLINK, "href", "http://stackoverflow.com/" );

text.textContent = "Hello, Stack!";
text.setAttribute( "x", 12.5 );
text.setAttribute( "y", 37.5 );
text.setAttribute( "font-size", 25 );

container.appendChild( svg );
svg.appendChild( a );
a.appendChild( text ) ;

console.log( container.innerHTML );