Css! The role of important

Source: Internet
Author: User

! Important is a syntax defined in CSS1 to improve the application priority of a specified style rule. Syntax format {cssRule! Important} {* cssRule! Important} the css rule has become very popular today in the production of web pages. I used to understand it in the 'browser identification? 'stage, but I have not really studied it, but now it has changed. Here are several examples. Example 1: CSS # Box {color: red! Important; color: blue; padding: 30px; width: 300px; border: 1px solid pink;} Html <div id = "Box"> in different browsers, the color of this line should be different! </Div> you can understand this syntax in browsers that support this syntax, such as Firefox, Opera, and Chrome! The priority of important. The font color shows the red color, while the IE color shows the blue color. Because the IE browser does not recognize it! Important, not recognized by IE browser! Important, and! Important has a higher priority. Then let's look at the following example. We only need to switch the color attribute in the CSS style to the next order. What will happen if the Html code remains unchanged? CSS # Box {color: blue; color: red! Important; padding: 30px; width: 300px; border: 1px solid pink;} in this case, both the IE browser and the IE browser recognize the font color. Although the IE browser does not recognize it! Important, but it recognizes this sentence "color: red! In important; ", color: red. Therefore, in IE, the browser first identifies "color: blue" and then "color: red! The color: red in important; "overwrites the previous" color: blue ", so the font color is red.

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.