The use of!important in CSS

Source: Internet
Author: User

This article uses the latest IE10 and Firefox and Chrome tests (as of May 27, 2013 22: at: Athe principle of CSS: We know that CSS write in different places have different priorities,. css file DefinitionsThe < element style property, but if used!important, things will become different. First, let's look at the following code:<! DOCTYPE Html>"Content-type"Content="text/html; Charset=utf-8"><title> Test in CSS! Important difference </title> "Text/css">. testclass{Color:blue!important;}</style><body> <divclass="TestClass"style="color:red;">testing the important in CSS</div></body>Although the style of the element has the definition of the TestClass class, it is used in the CSS definition aboveThe!important definition is the highest priority, whether in ie6-10 or Firefox and Chrome are all consistent and show blue. This also shows that IE6 can be identified!important, but this is a flaw of IE6. If written in the following style, IE6 is not recognized:. testclass{color:blue!important;color:red;} In this way, it appears red when displayed under IE6. Of course, IE6 can also be identified by the following methods:. testclass{Color:blue!important;} . testclass{color:red;} It is also possible to make the IE6 appear blue by the above method. The above example illustrates the use ofThe CSS definition of!important is the highest priority. Just in the IE6 out a little bit of bug, note that the writing method is generally easy to avoid.

The use of!important in CSS

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.