aFarkas / html5shiv

This script is the defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.
http://paulirish.com/2011/the-history-of-the-html5-shiv/
9.88k stars 2.56k forks source link

Can someone help me understand how this works #197

Open bryanwillis opened 8 years ago

bryanwillis commented 8 years ago

I've been using html5shiv for years now. I have a mac so I've never actually seen what it does beside a browserstack test I did a year or so back.

I guess what I'm confused is how this is supporting IE9, Safari 4, And FF 3. My best guess on Safari 4 and FF 3 is that they recognize IE conditional comments somehow. But this still doesn't explain that how this supports IE9.

Usage / documentation has always been suggested implementing like this:

<!--[if lt IE 9]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

To support IE 9 shouldn't this be something like ...

<!--[if lte IE 9]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

Personally I use either css reset / bootstrap / html5 boilerplate on all my sites so the IE9 styling doesn't affect me one way or the other I'm just curious / confused on what I'm missing here...

bryanwillis commented 8 years ago

Logically seems this would be the best way to include it so it works for IE9 and wont render in IE5:

<!--[if !(IE 5)]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->
boorge commented 11 months ago

Your proposed conditional comment <!--[if !(IE 5)]> is not a valid syntax for conditional comments in Internet Explorer. Conditional comments use specific syntax that includes checks for versions, not boolean conditions like "!(IE 5)".

If your goal is to include the HTML5 Shiv for IE9 and above while avoiding rendering for IE5, you can use the following conditional comment:

<!--[if gte IE 9]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->