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

Web page creation question: Image file path

This article is original by 123WORDPRESS.COM Ligh...

JS cross-domain solution react configuration reverse proxy

Cross-domain solutions jsonp (simulate get) CORS ...

Detailed explanation of Javascript Echarts air quality map effect

We need to first combine the air quality data wit...

Page Refactoring Skills - Javascript, CSS

About JS, CSS CSS: Stylesheet at the top Avoid CS...

Analysis of the implementation of MySQL statement locking

Abstract: Analysis of two MySQL SQL statement loc...

MySQL Series 3 Basics

Table of contents Tutorial Series 1. Introduction...

Comparison of the usage of EXISTS and IN in MySQL

1. Usage: (1) EXISTS usage select a.batchName,a.p...

Bootstrap 3.0 learning notes button style

This article mainly explains the style of buttons...

HTML+CSS3 code to realize the animation effect of the solar system planets

Make an animation of the eight planets in the sol...

Introduction to fork in multithreading under Linux

Table of contents Question: Case (1) fork before ...

A brief analysis of MySQL's lru linked list

1. Briefly describe the traditional LRU linked li...