HTML compatibility Problem--hack technology

Source: Internet
Author: User

first of all: The purpose of this article is to describe to you the issue of our meeting IE8 version and Firefox compatibility.

For different browsers to write different CSS process, this is called CSS hack, also known as CSS hack, I believe you will be more difficult to solve the compatibility problems have a certain interest.

Note the point:

Online A lot of information often put!important also as a hack paragraph, in fact, this is a misunderstanding.!important is often used by us to change the style, not the compatible hack. The cause of this misunderstanding is that IE6 in some cases do not actively identify!important, in order to often be mistaken for the identification of IE6 hack. However, the home note that IE6 is not recognized in some cases (IE6, the same bracket for the same style attribute definition, where the addition of important important tag is ignored, for example: {background:red!important; Background:green;} IE6 is explained below as background green, other browsers are interpreted as background red; If this same style is defined in a different bracket, one of the important is important normal, example: Div{background:red!important} div{ Background:green}, when all browsers are interpreted uniformly as the background color is red)

CSS hack differences IE6, IE7, IE8, Firefox compatibility issues

1. Differentiate between IE and non-IE browsers

Cases:

#tip {background:blue;/* IE background blue */Background:red\9;/*ie6, IE7, IE8 background red */}

2. Distinguishing Ie6,ie7,ie8,ff

Distinguishing symbols: "\9", "*", "_"

Example:#tip {background:blue;/*firefox background blue */BACKGROUND:RED\9;/*IE8 background red */*background:black;/*ie7 background Black */ _BACKGROUND:ORANGE;/*IE6 Background Orange */}

Description: Because the IE series browser readable "\9", IE6 and IE7 readable "*" (font size), in addition to IE6 can be identified "_" (bottom line), so you can write down in sequence, it will let the browser correctly read to understand the CSS syntax, so you can effectively distinguish between versions of IE and IE browser (Like a Firefox, Opera, Googlechrome, Safari, etc.).

3. Distinguish IE6, IE7, Firefox

Distinguishing symbols: "*", "_"

Cases:

#tip {Background:blue;/*firefox background blue */*background:black;/*ie7 background change */_background:orange;/*ie6 background turn orange */}

Description: IE7 and IE6 readable "*" (font size), IE6 can read "_" (bottom line), but IE7 read "_", in Firefox (IE) the full method to identify "*" and "_", so you can differentiate between IE6, IE7, Firefox

4. Distinguish between IE7 and Firefox

Distinguishing symbols: "*", "!important"

Cases:

#tip {Background:blue;/*firefox background turns blue/*background:green!important;/*ie7 background green */}

Note: Because Firefox can identify "!important" but the method to identify "*", IE7 can also understand "*", "!important", so you can distinguish between the two symbols IE7 and Firefox.

5. Distinction between IE6 and IE7 (Act 1)

Distinguishing symbols: "*", "_"

Cases:

#tip {*background:black;/*ie7 Background change */_BACKGROUND:ORANGE;/*IE6 background orange */}

Note: IE7 and IE6 can identify "*" (font size), but IE6 can identify "_" (bottom line), IE7 but the method of identification, through the IE7 method to read the characteristics of "_" can be easily separated IE6 and IE7 between the difference.

6. Distinction between IE6 and IE7 (Act 2)

Difference symbol: "!important"

Cases:

#tip {background:black!important;/*ie7 Background change */BACKGROUND:ORANGE;/*IE6 background orange */}

Description: Because IE7 can read "!important;" But IE6 but not, the reading step of the CSS is from top to bottom, so the IE6 read by the method identification "!important" jump directly to the next reading CSS, so the background will be orange.

7. Distinguish between IE6 and Firefox

Difference symbol: "_" "Example":

#tip {Background:black;/*firefox Background change */_BACKGROUND:ORANGE;/*IE6 background orange */}

Note: Because IE6 can identify "_" (bottom line), but Firefox is not, so you can use this difference to separate Firefox and IE6, effectively achieve csshack.

Summarize:

Hopefully these hack technical summaries will help developers who need help. Also hope that we will not be the compatibility of the IE series of tangled too much!

HTML compatibility Problem--hack technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.