The principle of CSS:
We know that CSS is written in different places with different priorities,. css file definitions < elements in the style, but if you use!important, things will get a difference.
First, let's look at the following code:
<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Test the CSS in! Important differences</title> </Head> <styletype= "Text/css">. TestClass{Color:Blue!important;}</style><Body> <Divclass= "TestClass"style= "color:red;">testing the important in CSS</Div></Body></HTML>
Although the style of the element has the definition of the TestClass class, the!important-qualified definition in the above CSS definition is the highest priority, both in the ie6-10 or in Firefox and Chrome, both of which are displayed in blue.
This situation can also indicate that IE6 can identify!important, but this is a flaw in 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 shows that CSS definitions using!important have the highest precedence. 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