// create a new div element
var divTag = document.createElement("div");
// and give it some content
var contentNode = document.createTextNode("Hello World");
// add the text node to the newly created div
divTag.appendChild(contentNode);
// adding 'id' attribute with value "root" to div element.
divTag.setAttribute('id', "root");