Created
June 29, 2014 21:01
-
-
Save herereadthis/f035f18a22b503d785a8 to your computer and use it in GitHub Desktop.
Bare-Bones HTML5 "Shiv" for IE8 and IE7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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