When debugging my ASP.NET MVC (Razor-based) web site in IE10, I need to still set IE-specific css. When using IE conditional comments, the following syntax works, when switching IE10 to IE8 Standard rendering mode:
<!--[if IE]><!-->
<link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css">
<!--<![endif]-->
And this – does not:
<!--[if IE]>
<link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css">
<![endif]-->
The later syntax is given as an example one on most of the sites that provide info on conditional comments, including the official page on MSDN. What’s the difference between these two? Thank you in advance.
Use “Downlevel-revealed Conditional Comments” to get it working…
Syntax:
Example:
More info:
The downlevel-revealed conditional comment syntax is flagged as invalid HTML by some validation services. Additional characters can be added to construct a valid HTML Comment before and after the HTML content to be revealed.
In the example above, the negative conditional expression prevents Internet Explorer from displaying the HTML content within the downlevel-revealed conditional comment block. However, if the conditional expression evaluates to true, the closing “–>” of the first comment appears along with the HTML content in Internet Explorer. To hide these characters from Internet Explorer users, add ”
Examples:
Here are some more examples of conditional comments.
contents taken from Valid HTML for downlevel-revealed conditional comments