Skip to content

Instantly share code, notes, and snippets.

@herereadthis
Created June 29, 2014 21:01
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 herereadthis/f035f18a22b503d785a8 to your computer and use it in GitHub Desktop.
Save herereadthis/f035f18a22b503d785a8 to your computer and use it in GitHub Desktop.
Bare-Bones HTML5 "Shiv" for IE8 and IE7
var html5Elements = [
'abbr', 'article', 'aside', 'bdi', 'data', 'datalist',
'figcaption', 'figure', 'footer', 'header', 'main', 'mark', 'meter',
'nav', 'output', 'progress', 'section', 'summary', 'time'];
headElement = document.head || document.getElementsByTagName('head')[0],
blockCSS = 'article,aside,figcaption,figure,footer,header,main,nav,section{display: block;}';
insertStyle = document.createElement('style');
for (var i = 0; i < html5Elements.length; i++) {
document.createElement(html5Elements[i]);
}
insertStyle.type = 'text/css';
if (insertStyle.styleSheet){
insertStyle.styleSheet.cssText = blockCSS;
}
else {
insertStyle.appendChild(document.createTextNode(blockCSS));
}
headElement.appendChild(insertStyle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment