title: How to create a <style> tag with Javascript?
body: <p>I'm looking for a way to insert a <code>&lt;style&gt;</code> tag into an HTML page with JavaScript.</p>
  
  <p>The best way I found so far:</p>
  
  <pre><code>var divNode = document.createElement("div");
  divNode.innerHTML = "&lt;br&gt;&lt;style&gt;h1 { background: red; }&lt;/style&gt;";
  document.body.appendChild(divNode);
  </code></pre>
  
  <p>This works in Firefox, Opera and Internet Explorer but not in Google Chrome. Also it's a bit ugly with the <code>&lt;br&gt;</code> in front for IE.</p>
  
  <p>Does anyone know of a way to create a <code>&lt;style&gt;</code> tag that</p>
  
  <ol>
  <li><p>Is nicer</p></li>
  <li><p>Works with Chrome?</p></li>
  </ol>
  
  <p>Or maybe</p>
  
  <ol>
  <li><p>This is a non-standard thing I should avoid</p></li>
  <li><p>Three working browsers are great and who uses Chrome anyway?</p></li>
  </ol>