var styleElem = document.head.appendChild(document.createElement("style")); styleElem.innerHTML = "#YOUR_DIV:before {background: black;}";