Instantly share code, notes, and snippets.

Embed
What would you like to do?
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