element. When dynamically creating CSS rules it is alays better to create a new stylesheet, and adding rules to it. The element is structural and the various attributes need to be added or in the case of say, a paragraph ("p") or "pre" a text node (created using createTextNode) is required to contain the visible text. To create elements, you need to use the relevant document's createElementNS() method, passing in the SVG namespace and the tag name. Using .className property: This property is used to add a class name to the selected element. para.appendChild(t); // Append the text to . (Each HTML element has an innerHTML property that defines both the HTML code and the text that occurs between that element’s opening and closing tag. How to check if checkbox is checked or not using only JavaScript. Adding a new element to a document is very logical. Animating a Lightbox with CSS & Javascript is a perfect example where you need to add CSS to a stylesheet dynamically. Let's make it a bit more useful: newlink = document.createElement('a'); newlink.setAttribute('class', 'signature'); newlink.setAttribute('href', 'showSignature (xyz)'); Append said