<svg viewBox="0 0 200 100" id="mySvg">
<rect width="100" height="100" fill="blue" />
</svg>SVGAnimatedRect: baseVal property / notebook
SVGAnimatedRect: baseVal property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const svgElement = document.getElementById("mySvg");
const animatedRect = svgElement.viewBox.baseVal;
// Access the non-animated base value
console.log(animatedRect.x); // 0
console.log(animatedRect.y); // 0
console.log(animatedRect.width); // 200
console.log(animatedRect.height); // 100