0

why i have to add value of width and height next to svg and next to rect

hi guys i have one question <svg width="2000" height="2000"> <rect width="300" height="100" x="20" y="20" fill="green" /> </svg> i don`t understand what is the difference between <svg width="2000" height="2000"> and rect width="300" height="100"

26th Jan 2020, 11:13 PM
Roland Remon
Roland Remon - avatar
6 ответов
+ 5
Svg is a method to draw any 2-D shapes and rect is a part of that . Do you need to first desied SVG and then it's shapes
26th Jan 2020, 11:39 PM
🇮🇳Abhay Pratap Singh🇮🇳
🇮🇳Abhay Pratap Singh🇮🇳 - avatar
+ 4
BroFar i don't know about canvas sir thanks a lot😊
27th Jan 2020, 12:27 AM
🇮🇳Abhay Pratap Singh🇮🇳
🇮🇳Abhay Pratap Singh🇮🇳 - avatar
+ 4
®OHiT_$HaRma ™ okay think in terms of a piece of paper and you are drawing on it... you have a set 10½ by 8 size sheet and want to draw an apple an orange and a banana in a bowl
27th Jan 2020, 1:11 AM
BroFar
BroFar - avatar
+ 2
svg is the canvas, setting is width and height affects its size on the webpage rect is for a rectangle, you need to specify its width and height and also position. If rectangle size exceeds canvas size, it'll be cropped, see example 2. solution is viewBox attribute, see example 3. https://code.sololearn.com/WgBw7Yq20ZkR/?ref=app
26th Jan 2020, 11:37 PM
Gordon
Gordon - avatar
+ 2
®OHiT_$HaRma ™ yes you need a background similarly to js canvas thinking the SVG tags set the sheet size and width before you can draw on / in it
27th Jan 2020, 12:08 AM
BroFar
BroFar - avatar
0
thanks for help
28th Jan 2020, 7:26 PM
Roland Remon
Roland Remon - avatar