Skip to content

Instantly share code, notes, and snippets.

@mediamichael
Created October 20, 2014 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mediamichael/b1c7f577d3d054b94cf1 to your computer and use it in GitHub Desktop.
Save mediamichael/b1c7f577d3d054b94cf1 to your computer and use it in GitHub Desktop.
Append CSS with JS
var css = '@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,900,700,500,500italic,700italic,900italic);',
header = 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));
}
header.appendChild(style);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment