How to use SVG as a Placeholder, and Other Image Loading Techniques So first, we have to get the object and then access its contentDocument. Lets move on to a star. If I move a property outside that wrapper and set() it, we get an inline style. By making one small change to our code we can make it work as it should, observe below: Now, the differences under the hood between createElementNS and createElement, I couldn't tell you, though it's clear that it somehow tells the browser it is creating an SVG rectangle element, rather than just a rectangle element to go, um, somewhere else, somehow, I guess. Then set its attributes like (src, height, width, alt, title, etc). Well, why not just use jQuery or D3? Any advice on if these value can be set in this fashion? You can start with pen and paper and draw a draft first to get an estimate. How can I validate an email address in JavaScript? This all works fine until I try to append an img to the SVG using a local png file. Redoing the align environment with a specific formatting. how to use javascript in SVG code example You can dynamically create curves and paths too, but thats a bit more involved so Ill save it for another tutorial. You will need a height or a width attribute (or both if your SVG has no inherent aspect ratio). Im adding a 4 unit stroke so I subtract the 2 units from the radius since strokes are center aligned. SVG images can be scaled to any size. Instead, let's create a new CSS rule inside the style tags or an . <body> // Paste the SVG code here. Now I am experimenting to develop an small library to enable svg geometries to make them snappable on top/inside others svg elements. I have an external SVG that I have displayed within an Object tag on my website and it works great on desktop, but it isn't working on mobile or tablet despite following your instructions about making the SVG responsive. Is there anything additional that needs to be done for this? This means that we can animate parts of an image from code, make it interactive, or turn things around and generate graphics from data. Does ZnSO4 + H2 at high pressure reverses to Zn + H2SO4? A rectangle, and two circles. so it adds