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 mented out. I've always wondered, but was too afraid to ask if mented out code like this is needed or not. In other words if I am using IE6 or IE7 will the appropriate line above bee 'activated' somehow or does the simple fact that it is mented out mean that it will never get called?
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 mented out. I've always wondered, but was too afraid to ask if mented out code like this is needed or not. In other words if I am using IE6 or IE7 will the appropriate line above bee 'activated' somehow or does the simple fact that it is mented out mean that it will never get called?
Share Improve this question edited Feb 29, 2012 at 11:31 Paul Alan Taylor 10.7k1 gold badge29 silver badges44 bronze badges asked Feb 29, 2012 at 11:27 Sachin KainthSachin Kainth 46.8k86 gold badges209 silver badges308 bronze badges 1- I wish I could mark all of you are the right answer. – Sachin Kainth Commented Feb 29, 2012 at 11:40
4 Answers
Reset to default 7These are conditional ments.
As far as HTML is concerned, they are mented out.
Internet Explorer violates the standard to ignore the ments 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.
This is called browser specific conditional ments. 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
Theses ments are conditional statements only executed by IE, so yes, if you are using IE6 or IE7 then these will bee active, i.e. not mented.
These are valid conditional ment instructions. They are obeyed by IE and are not "mented out" at all. Do not delete them unless you actually want to remove the behaviour.