Search code examples
htmlmodernizrhtml5shiv

HTML5 Shiv and Modernizr


I'm using Modernizr, I downloaded with "HTML5Shiv" I checked the checkbox.

But My question is... Do I have to put a conditional like this:

<!--[if lt IE 9]>
include html5shiv from Modernizr
<![endif]-->

And if the answer is yes, what script do I have to include there?


Solution

  • You don't need a conditional comment; the html5shiv script is automatically added to the Modernizr source.

    According to the docs:

    As of Modernizr 1.5, this script is identical to what is used in the popular html5shim/html5shiv library. Both also enable printability of HTML5 elements in IE6-8, though you might want to try out the performance hit if you have over 100kb of CSS.

    However, if you want to take advantage of Modernizr's shiv, you do need to place the script in the <head> tag:

    The reason we recommend placing Modernizr in the head is two-fold: the HTML5 Shiv (that enables HTML5 elements in IE) must execute before the<body>, and if you’re using any of the CSS classes that Modernizr adds, you’ll want to prevent a FOUC.