Skip to content

Instantly share code, notes, and snippets.

@ajhsu
Last active October 26, 2018 03:45
Show Gist options
  • Save ajhsu/0f873d49a23cf48134e994ac8f248c09 to your computer and use it in GitHub Desktop.
Save ajhsu/0f873d49a23cf48134e994ac8f248c09 to your computer and use it in GitHub Desktop.
Dynamically injects an inline stylesheet into a web page
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
body {
background-color: yellow;
}
`;
document.querySelector('head').appendChild(style);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment