symbol element[1]
. id attributewidth and height attributesviewBox attributepreserveAspectRatio attributewidth, height, and viewBox attributes is not present, the symbol will be rendered without scaling.width, height, and viewBox attributes are present:width and height attributes, and the viewBox width and heightpreserveAspectRatio attribute is not present or is different to none, then the coordinates of the symbol will be scaled with the same value for both X and Y axis[2]
preserveAspectRatio attribute:none means that the scaling for the X and Y axis is independantmeetOrSlice optional parameter of the preserveAspectRatio attribute is not taken into account.
<svg viewBox="0 0 80 20" xmlns="http://www.w3.org/2000/svg"> <symbol id="myDot"> <circle cx="5" cy="5" r="5" /> </symbol> <use href="#myDot" x="20" y="5" style="opacity:0.8" /> </svg>
<svg viewBox="0 0 80 20" xmlns="http://www.w3.org/2000/svg"> <symbol id="myDot" width="10" height="10" viewBox="0 0 2 2"> <circle cx="1" cy="1" r="1" /> </symbol> <use href="#myDot" x="5" y="5" style="opacity:1.0" /> <use href="#myDot" x="20" y="5" style="opacity:0.8" /> <use href="#myDot" x="35" y="5" style="opacity:0.6" /> <use href="#myDot" x="50" y="5" style="opacity:0.4" /> <use href="#myDot" x="65" y="5" style="opacity:0.2" /> </svg>In this example, the coordinates will be scaled from a 5 = 10 / 2 factor on both the X and Y axis.
preserveAspectRatio attribute different from none are considered identicallyCopyright 2021-2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD-3-Clause License