Home >Web Front-end >HTML Tutorial >HTML conditional comment usage explanation

HTML conditional comment usage explanation

不言
不言Original
2018-04-27 14:11:571704browse

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

HTML conditional comment usage interpretation


The comment content takes the style as an example, as follows:

1. Supports all IE browsers

<!--[if IE]>
<link rel="stylesheet" href="all-ie-only.css" type="text/css"/>
<![endif]-->

2. Supports non-IE browsers

<!--[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]-->

3 , only supports IE10

<!--[if IE 10]>
<link rel="stylesheet" type="text/css" href="ie10.css">
<![endif]-->

4, supports versions below IE10 (IE9 and below)

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:

5, version higher than IE9 (IE10 and IE10 or above)

<!--[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]-->

6, specify more IE version

<!--[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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn