ExampleEdit

by moob

HTML

<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/symbol -->

<svg class="source">
    <symbol id="sym01" viewBox="0 0 150 110">
    
        <circle cx="50" cy="50" r="40" stroke-width="8" stroke="red" fill="red" />
        <circle cx="90" cy="60" r="40" stroke-width="8" stroke="green" fill="white" />
    </symbol>
</svg>



<hr />
<svg class="mySymbolInstance1">
    <use xlink:href="#sym01" />
</svg>
<hr />
<svg class="mySymbolInstance2">
    <use xlink:href="#sym01" width="100" />
</svg>
<hr />

CSS

svg.source {
    display: none;
}


/* svgs have a default size of 300x150 */

svg.mySymbolInstance1 {
    width: 50px;
    height: 90px;
}

svg.mySymbolInstance2 {}