<html>
<head></head>
<body>
<h1>test</h1>
<script>
var css = 'h1 { background: red; } body {background-color: lightgray; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
</script>
</body>
</html>