<svg
xmlns="http://www.w3.org/2000/svg"
width="400"
height="200"
preserveAspectRatio="xMidYMid meet">
<circle cx="100" cy="100" r="50" fill="blue" />
</svg>SVGPreserveAspectRatio: align property / notebook
SVGPreserveAspectRatio: align 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.querySelector("svg");
// Access the align property
console.log(svgElement.preserveAspectRatio.baseVal.align); // Output: 6 (SVG_PRESERVEASPECTRATIO_XMIDYMID)