Reputation: 46750
In my _Layout.cshtml file I have the following lines
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="/Content/css/ie7.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="/Content/css/ie6.css" />
<![endif]-->
Both these lines are commented out. I've always wondered, but was too afraid to ask if commented out code like this is needed or not. In other words if I am using IE6 or IE7 will the appropriate line above become 'activated' somehow or does the simple fact that it is commented out mean that it will never get called?
Upvotes: 4
Views: 201
Reputation: 1746
This is called browser specific conditional comments. It will choose, the stylesheet specified in the first line if you use IE 7 and the style sheet specified in the second line if you use the IE 6
Upvotes: 5
Reputation: 31071
These are valid conditional comment instructions. They are obeyed by IE and are not "commented out" at all. Do not delete them unless you actually want to remove the behaviour.
Upvotes: 2
Reputation: 943601
These are conditional comments.
As far as HTML is concerned, they are commented out.
Internet Explorer violates the standard to ignore the comments under certain conditions (i.e. when they start with a [unless you are some version of ie]
string) so it will "activate" the code inside.
Upvotes: 7
Reputation: 43084
Theses comments are conditional statements only executed by IE, so yes, if you are using IE6 or IE7 then these will become active, i.e. not commented.
Upvotes: 4