Add css inline style using JavaScript

Content

Add inline css style using JavaScript via document.createElement.

var style = document.createElement('style'); style.textContent = '.alert { color: red; };'; document.head.appendChild(style);