Parsing of!important and * and _ symbols in CSS styles

Source: Internet
Author: User
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!

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.