ViewBox
A regular img
tag in the HTML will allow the SVG to take up all the width in the current HTML tag.
We can set the width
or height
element of the img
tag (but preferably not both) to set the actual size of the image.
<img width="100px" src="../examples/viewbox.svg">
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="white" stroke="black" stroke-width="1" />
<rect width="100" height="50" fill="blue" />
</svg>