I am building a svg element in pure Javascript, but I don't manage to add images to it : You need this to set the href attribute, although why you're calling the variable pngImage when it sets a svg image is beyond me. Any clue you may have pointing me to the right direction would be greatly appreciated! Right-click on the image, hit "Inspect Element" and view the converted image below but this time, you'll see it as an SVG element:. With you every step of your journey. Like HTML, SVGs are represented using the Document Object Model (DOM) and so can be manipulated with Javascript relatively easily, especially if you are familiar with using JS with HTML. The width and height property define how much space the image takes up in the browser. When selecting an SVG in Pinegrow there are two checkboxes in the Properties panel , 'Fill with current color' and 'Stroke with current color'. Brilliant. See the Pen var imgageData = getCanvas. Here we only have the two most simple commands, move to (M) and line to (L). This lets you to have separation of concerns, and easily reuse the JS for multiple SVGs on a website. However, there is also an issue that the SVG within the object might not have loaded by the time we reach the script element (which I'm assuming you've added to the end of the HTML document). Note that these functions are slightly different from the standard getAttribute and setAttribute methods because the elements are not HTML elements, rather in the SVG namespace (NS stands for namespace). It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. Our old loop from the last section will become the columns. Throughout the rest of this article, Ill be using some CSS, some presentation attributes and some inline styles (just for variety). so it adds