Javascript examples for DOM HTML Element:Style
You can create a <style> element by using the document.createElement() method:
<!DOCTYPE html> <html> <head> </head>/*from w w w . j a va 2 s .c o m*/ <body> <button onclick="myFunction()">create a STYLE element, and place it in the head section</button> <script> function myFunction() { var x = document.createElement("STYLE"); var t = document.createTextNode("body {font: 40px caption;}"); x.appendChild(t); document.head.appendChild(x); } </script> </body> </html>