svg width and height set auto code example
Example 1: css svg width 100%
<svg height="100%" width="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
<path d="M0 0 L100 0 L50 100 Z" />
</svg>
Example 2: svg auto size
// Javascript to run after document load
var svg = document.getElementsByTagName("svg")[0];
var bbox = svg.getBBox();
svg.setAttribute("width", bbox.width + "px");
svg.setAttribute("height", bbox.height + "px");
svg.setAttribute("viewBox", `${bbox.x} ${bbox.y} ${bbox.width} ${bbox.height}`);