How to determine each version of IE browser in HTML and CSS

高洛峰
Release: 2017-03-27 17:38:14
Original
2076 people have browsed it

1. In HTML code

When writing web page code, the compatibility of various browsers is an issue that must be considered. Sometimes it is impossible to find a writing method suitable for all browsers, so you can only write according to the browsing The code that differentiates the type of device is the judgment code that needs to be used at this time. In the

HTML code, the code to distinguish various browsers is as follows, taking ie6 as an example






##

The above code writing methods are for each version of IE browser. In other browsers, these codes will be interpreted as Html comments and ignored directly.


Recognized by all except IE

2. In the CSS code

In the CSS code, you can write code to distinguish the browser according to the special code that each browser can independently recognize, for example, it can be read by IE series browsers [\ 9], and IE6 and IE7 can read [*], and IE6 can recognize [_] (underscore); because
is read from top to bottom when reading CSS, the same attribute written later will take effect, so You can write them down in order, so that each browser can correctly read and understand the CSS syntax, effectively distinguishing various types or versions:

.classname{

blue; / *The background of non-IE browsers such as Firefox turns blue*/

red \9; /*The background of IE8 turns red*/
*black; /*The background of IE7 turns black*/

_background:orange; / *IE6 background turns orange*/

}


.classname {
black !important; /*Non-IE6 background turns black*/
background:orange; /*IE6 The background turns orange*/
}

Because other browsers can read "!important;" but IE6 cannot.

The above is the detailed content of How to determine each version of IE browser in HTML and CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template