Commented HTML

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 of these lines are commented out. I always wondered, but was too afraid to ask if a code such as this was needed or not. In other words, if I use IE6 or IE7, will the corresponding line above be β€œactivated” in any way, or just the fact that it is commented out means that it will never be called?

+4
source share
4 answers

These are conditional comments .

As for HTML, they are commented out.

Internet Explorer breaks the standard to ignore comments under certain conditions (that is, when they begin with the line [unless you are some version of ie] ), so it will "activate" the code inside.

+7
source

This is called conditional browser commentary. He will choose the stylesheet listed on the first line if you are using IE 7 and the stylesheet listed on the second line if you are using IE 6

+5
source

Abstracts are conditional statements executed only by IE, so yes, if you use IE6 or IE7, then they will become active, that is, they will not comment.

+4
source

These are valid conditional comments . They are subordinate to IE and do not "comment" at all. Do not delete them unless you really want to delete the behavior.

+2
source

Source: https://habr.com/ru/post/1398995/


All Articles