Two different width and height attributes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Two different width and height attributes

Why do we have width & height attributes for Svg and also a different eight & height attribute for <rect> ?

17th Oct 2018, 7:05 AM
David Ogbuehi
David Ogbuehi - avatar
1 Answer
+ 2
<svg> is the root of all your svg shape elements, then height and width define the svg canvas size. Futhermore every svg shape can use own width and height attribute which values can be valutated in different ways. At example, if <svg> root element define an attribute viewBox like viewBox="0 0 30 30" (indicate a virtual coordinate system space where 0 0 is at top left of svg, 30 30 mean width height of this coordinate system space), all shape height/width will not represent in pixels but proportion (width="15" set a shape like half root width)
17th Oct 2018, 7:17 AM
KrOW - avatar