<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>Dynamic sheet append (&lt;style&gt;)</title>
  <script type="text/javascript">
   var style = document.createElement("style");
   var text = document.createTextNode("body { color: red; }");
   style.appendChild(text);
   document.getElementsByTagName("head")[0].appendChild(style);
   // note: when this runs, we've only parsed as far as the next line,
   // so the style element below doesn't exist, so we "append"
   // before that element.
  </script>
  <style type="text/css">
   body { color: green; }
  </style>
 </head>
 <body>
  <p>This text should be green.</p>
 </body>
</html>
