Skip to content

Instantly share code, notes, and snippets.

@saibotsivad
Last active January 29, 2018 17:40
Show Gist options
  • Save saibotsivad/6d35c0d78d840dba8a98e1ed24eca8aa to your computer and use it in GitHub Desktop.
Save saibotsivad/6d35c0d78d840dba8a98e1ed24eca8aa to your computer and use it in GitHub Desktop.
Better Web Styles
// the long version
(function(doc, url){
var css = doc.createElement('style');
css.setAttribute('type', 'text/css');
css.appendChild(doc.createTextNode('@import url(' + url + ')'));
doc.getElementsByTagName('head')[0].appendChild(css);
}(document, 'http://site.com/style.css'))
// the short version (make sure to update the URL)
(function(doc, url){var css = doc.createElement('style');css.setAttribute('type', 'text/css');css.appendChild(doc.createTextNode('@import url(' + url + ')'));doc.getElementsByTagName('head')[0].appendChild(css);}(document, 'http://site.com/style.css'))
/*
You will need to host this file somewhere. Github serves this file
as `text/plain` so the browser won't interpret it correctly.
*/
body {
max-width: 30em;
margin: 0 auto;
font-size: 1.3em;
line-height: 1.4;
font-family: Georgia, Cambria, "Times New Roman", Times, serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment