JSFiddle - React, Tailwind, and code Playground

CSS

div {
 border: 1px dotted red;
 padding: 10px;    
}

JavaScript

var div = document.createElement("div");
div.style.border = "1px dotted red";
//div.onmouseover=function(){div.style.color = "red"};
div.setAttribute("onmouseover","this.style.color='red'");
div.innerHTML = "I'm the div";

var str = div.innerHTML; //Writes the textual content: "I'm the div"
var str2 = div.outerHTML; //Writes the HTML code without the function: "<div>I'm the div</div>"

document.body.appendChild(div);
document.body.appendChild(document.createTextNode(str));
document.body.appendChild(document.createElement("p"));
document.body.appendChild(document.createTextNode(str2));