Home >Web Front-end >HTML Tutorial >HTML conditional comment usage explanation
This article mainly introduces the usage interpretation of HTML conditional comments, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
The comment content takes the style as an example, as follows:
<!--[if IE]> <link rel="stylesheet" href="all-ie-only.css" type="text/css"/> <![endif]-->
<!--[if !IE]> <link rel="stylesheet" href="not-ie.css" type="text/css"/> <![endif]-->
The above is that all browsers except IE browser recognize this style. In addition, the article "How To Create an IE-Only Stylesheet" by CSS-TRICKS provides another way of writing:
<!--[if !IE]><!--><link rel="stylesheet" type="text/css" href="not-ie.css" /><!--<![endif]-->
<!--[if IE 10]> <link rel="stylesheet" type="text/css" href="ie10.css"> <![endif]-->
This method is used in style sheets in browsers lower than IE10, in other words, except for IE10 All IE versions except .
<!--[if lt IE 10]> <link rel="stylesheet" type="text/css" href="ie9-and-down.css"> <![endif]-->
can also be written as
<!--[if lte IE 9]> <link rel="stylesheet" type="text/css" href="ie9-and-down.css"> <![endif]-->
We have also mentioned the difference between lt and lte before. lt means less than the version number, excluding the conditional version number itself; while lte means less than or Equal to the version number, including the version number itself
.
The above methods use the methods of less than (lt) and less than or equal to (lte) to judge. We can also use greater than gt
and greater than or equal to gte
To achieve the above effect:
<!--[if gt IE 9]> <link rel="stylesheet" type="text/css" href="ie10-and-up.css"> <![endif]-->
or
<!--[if gte IE 10]> <link rel="stylesheet" type="text/css" href="ie10-and-up.css"> <![endif]-->
<!--[if (IE 6)|(IE 7)|(IE 8)]> <link rel="stylesheet" type="text/css" href="ie6-7-8.css"> <![endif]-->
Reference:
https://www.cnblogs.com/hushufang/p/3708704.html
Related recommendations:
Usage of audio and video tags in HTML5
The above is the detailed content of HTML conditional comment usage explanation. For more information, please follow other related articles on the PHP Chinese website!