This article mainly introduces the detailed CSS style in the!important, *, _ Symbols Related materials, hope that through this article can help everyone, the need for friends can refer to the next
Detailed!important, *, _ symbols in CSS styles
!important, *, _ actually no use, are used to set the priority of the style, but the priority of the style you can arrange their own position to set, but you still have to read.
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>
"Hehe" Two words are defined two color, originally in color:red after Color:blue, the two words should be red, default to take the closest font color
But after Color:blue added!important, resulting in the highest priority of Color:blue, "hehe" Two words should be blue, the specific effect is as follows:
However, IE6 does not recognize the!important symbol in the style attribute, so it is the same as the original style priority, the "hehe" two words into a red.
The!important, *, and _ symbols in CSS styles are used to set priority, but these symbols are only applicable in specific browsers, as follows:
IE can recognize *; standard browsers (such as FF) do not recognize *;
IE6 can identify the *, but does not recognize!important;
IE7 can recognize *, can also identify!important;
FF does not recognize *, but can identify!important;
Underline "_", IE6 support underline, IE7 and Firefox do not support underline.
Therefore, you can differentiate Ie6,ie7,firefox by defining the following attributes in the Style property:
Background:orange;*background:green;_background:blue;
You can also differentiate Ie6,ie7,firefox by:
Background:orange;*background:green!important;*background:blue;
The following code:
<! DOCTYPE html>
It works as follows:
(1) IE7
(2) IE8 and above browser, including Firefox and so on.
(3) IE6
However, this difference can only be used for debugging, the real front-end programming should use JavaScript to determine the browser's identity, to determine the type of these browsers.
Finally, in fact, IE6 just can't recognize the!important in the style, if the code looks like this:
<! DOCTYPE html>
Whether it's in ie6-10 or Firefox and Chrome, it shows blue.
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!