In css! What does important mean?

Source: Internet
Author: User
Is to be compatible with IE/FF

Font-size: 12px! Important;
Font-size: 13px;
In IE, because IE does not understand it! Important, the font size is displayed according to the last set 13px
And FF ,! To improve the priority of important, the font size is based on! 12 px display of important flag

 

"! Important "ie6 cannot be identified, but FF can, so it is used to set the style for FF and IE6.0 respectively, because the two browsers have different interpretations of the code, as a result, sometimes the same style is different!
Later we arrived at IE7 "! Important "can be recognized again, so it cannot be used;
The current practice is to add "* + html" in front of the style in IE7, and write FF directly. FF cannot recognize the string "* + html", so that the style is compatible with the browser; however, the disadvantage is that the length of the style sheet is increased, and the loading time is delayed ~
But the best practice is to use JS to test the browser version and then link different style sheets!

 

First ,! The main purpose of important is to distinguish (IE6) and (IE7, FF). Note that IE6 is the same, and IE7 and FF are the same, because these two are fully supported and similar to the latest css.

Second, IE6 does not parse! Important (the latest css standards supported by IE6 are not completely supported), parse IE7 and FF! Important (supported)

Again, some css code is displayed differently in these two types of browsers (note that this is also used! The main cause of important), such as height: 21px;, is displayed in IE6 and (IE7, FF), and the latter (IE7, FF) is compared to the former (IE6) one pixel less.

Therefore, in order to ensure the consistency of the display effects of different browsers, we use two sentences for the two types of browsers,

ClassName {
Height: 22px! Important;
Height: 21px;
}


Height: 22px! Important; only parse IE7 and FF
Height: 21px; only parsed by IE6

The display effect of the two browsers is the same as that of the final two browsers. If you do not treat them differently, a simple sentence of height: 21px is used. In IE7 and FF, the display will have one pixel less height.

Related Article

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.