I couldn't understand one place in IE conditional comments in the HTML5-boilerplate. It's about this part:
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
The following two cases are quite straightforward,
- in cases of IE6/7, the condition "if gt IE 8" is FALSE, so it outputs
<!-- -->
; - in cases of non-IE, "[if gt IE8]" and "[endif]" are not recognized, "
<!--[if gt IE 8]><!-->
" and "<!--<![endif]-->
" are therefore standard HTML comments. So it outputs<html class="no-js">
;
What confuses me is the case of IE9. In case of IE9, the condition "if gt IE 8" is TRUE, so it outputs the body of IE condition:
<!--> <html class="no-js"> <!--
<!-->
is empty comment;<html class="no-js">
is regular HTML output;
But what about the ending "<!--
"? How is it handled? In my opinion, this beginning comment tag will turn everything following it into comments until it meets an end tag "-->
". Isn't this a huge problem?
But I have never seen anybody questioning about this. So am I missing something? Can somebody explain this to me? Any help is appreciated.
I can't point to any actual reference for how they parse these (CC have always been sparsely documented) and can't remember who came up with this pattern, but IE isn't passed
<!--> <html class="no-js"> <!--
it's passed only<html class="no-js">
It combines each full, valid comment block as the start and end of the conditional comments.Here's an example that shows it's not passed an open comment
http://htmlcssjavascript.com/samples/cc.html
That outputs....
"IE9+
Not an open comment -->"
in IE9. If it left a comment open, of couse, the "Not an open comment" bit would disappear.