Statement to determine browser version and compatible with multiple browsers

Statement to determine browser version and compatible with multiple browsers
<!--[if lte IE 6]>
<![endif]-->
Visible in IE6 and below

<!--[if lte IE 7]>
<![endif]-->
Visible in IE7 and below

<!--[if IE 6]>
<![endif]-->
Only IE6 version is visible

<![if !IE]>
<![endif]>
Versions other than IE

<!--[if lt IE 8]>
<![endif]-->
Visible in IE8 and below

<!--[if gte IE 7]>
<![endif]-->
Visible in IE7 and below

usage:
(1)
You can use the following code to detect the current IE browser version (note: the effect will not be seen in non-IE browsers) <!––[if IE]>
<h1>You are using Internet Explorer</h1> <!––[if IE 5]>
<h2>Version 5</h2> <![endif]––>
<!––[if IE 5.0]>
<h2>Version 5.0</h2> <![endif]––>
<!––[if IE 5.5]>
<h2>Version 5.5</h2> <![endif]––>
<!––[if IE 6]>
<h2>Version 6</h2> <![endif]––>
<!––[if IE 7]>
<h2>Version 7</h2> <![endif]––>
<![endif]––>
What if the current browser is IE, but the version is lower than IE5? You can use <!–[if ls IE 5]>. Of course, conditional comments can only be used in the IE5+ environment, so <!–[if ls IE 5]> will not be executed at all. lte: is the abbreviation of Less than or equal to, which means less than or equal to. lt: It is the abbreviation of Less than, which means less than. gte: is the abbreviation of Greater than or equal to, which means greater than or equal to. gt: It is the abbreviation of Greater than, which means greater than. ! : It means not equal, which is the same as the not equal to judgement operator in JavaScript

(2)
How to apply conditional comments is explained at the beginning of this article. Because different versions of IE browsers interpret the WEB standard pages we make differently, specifically, they interpret CSS differently. In order to be compatible with these, we can use conditional comments to define them separately and ultimately achieve the purpose of compatibility. For example: <!-- By default, the css.css style sheet is called first-->

<link rel="stylesheet" type="text/css" href="css.css" />< !-–[if IE 7]>

<!–- If the IE browser version is 7, call the ie7.css style sheet- –>

<link rel="stylesheet" type="text/css" href="ie7.css" />< ![endif]–->

<!–-[if lte IE 6]>

<!–- If the IE browser version is less than or equal to 6, call the ie.css style sheet-–>

<link rel="stylesheet" type="text/css" href="ie.css" />< ![endif]–> This distinguishes the execution of CSS between browsers lower than IE7 and IE6, achieving compatibility. At the same time, the default css.css in the first line can also be compatible with other non-IE browsers.

Note: The default CSS style should be located in the first line of the HTML document, and all content for conditional comment judgment must be located after the default style. For example, the following code is displayed in red when executed in IE browser, but in black when executed in non-IE browsers. If the conditional comment judgment is placed in the first line, it cannot be implemented. This example can well illustrate how to solve the compatibility problem between IE browser and non-IE browser. <style type="text/css"> body{ background-color: #000; } < /style> < !-–[if IE]>

<style type="text/css">body{background-color: #F00;}< /style>< ![endif]–->

At the same time, some people may try to use <!–-[if !IE]> to define the situation in non-IE browsers, but please note: conditional comments can only be executed in IE browsers. This code will not only not execute the definition under the condition in non-IE browsers, but will be ignored as a comment.

Normal is the default style, and conditional comments are performed only when special processing is required for IE browsers. In HTML files, not in CSS files.

These comments are now available in DWcs4: in "Window -> Code Snippet -> Comments". I haven't noticed the other versions.

<<:  Tutorial on installing Ceph distributed storage with yum under Centos7

>>:  Nodejs-cluster module knowledge points summary and example usage

Recommend

Ubuntu View and modify mysql login name and password, install phpmyadmin

After installing MySQL, enter mysql -u root -p in...

Comprehensive understanding of line-height and vertical-align

Previous words Line-height, font-size, and vertica...

mysql workbench installation and configuration tutorial under centOS

This article shares the MySQL Workbench installat...

How to use video.js in vue to play m3u8 format videos

Table of contents 1. Installation 2. Introducing ...

Vue3.0 implements the encapsulation of the drop-down menu

Vue3.0 has been out for a while, and it is necess...

Detailed graphic explanation of mysql query control statements

mysql query control statements Field deduplicatio...

Detailed explanation of deploying MySQL using Docker (data persistence)

This article briefly describes how to use Docker ...

Summary of HTML formatting standards for web-based email content

1. Page requirements 1) Use standard headers and ...

MySQL 5.7.17 installation and configuration tutorial under Linux (Ubuntu)

Preface I have installed MySQL 5.6 before. Three ...

HTML code example: detailed explanation of hyperlinks

Hyperlinks are the most frequently used HTML elem...

jQuery implements accordion small case

This article shares the specific code of jQuery t...