what actually width and height indicates in SVG | Sololearn: Learn to code for FREE!
+ 2

what actually width and height indicates in SVG

<svg width="2000" height="2000"> <circle cx="80" cy="80" r="50" fill="green" /> </svg> when i change svg width and height again it give sameresults why?

6th Jan 2019, 9:26 PM
Wasiq Abdullah
3 Réponses
+ 4
In the ‚Äúreal‚ÄĚ world, before you draw something you get a piece of paper. Well, <svg width="2000" height="2000"> creates an ‚Äúimaginary‚ÄĚ piece of paper that is 2000 units wide, by 2000 units high. And then you draw a circle, somewhere on your paper. Where exactly you place the circle, how ‚Äúbig‚ÄĚ is your circle and what ‚Äúit looks like‚ÄĚ, is given by the next line: <circle cx="80" cy="80" r="50" fill="green" /> Your circle has a radius of 50 units, its centre is located 80 units to the right from the left edge of your paper, and 80 units below from the upper edge of your paper. And it is all green. As long as you draw the circle inside the ‚Äúimaginary‚ÄĚ paper you have created, you don‚Äôt see any easily visible difference ‚Äď it‚Äôs only the ‚Äúbig picture‚ÄĚ that changes (i.e. where in relation to the whole area of the paper the circle is placed). But if you set width=‚ÄĚ100‚ÄĚ, height=‚ÄĚ100‚ÄĚ, then you will find out that the circle is incomplete ‚Äď just because your ‚Äúpaper‚ÄĚ is too small for the circle you want to draw, where you want to draw it. And this time, you have a difference that is easily visible. Hope this helps.
6th Jan 2019, 10:26 PM
Triantaphyllos Samaras
Triantaphyllos Samaras - avatar
6th Jan 2019, 10:17 PM
Ulisses Cruz
Ulisses Cruz - avatar
The width and height attributes of the <svg> element define the width and height of the SVG image.
6th Jan 2019, 10:12 PM
Ulisses Cruz
Ulisses Cruz - avatar