How to use!important declaration to enforce precedence in CSS

Source: Internet
Author: User
!important Declaration Enforcement priority

There is also one of the most invincible declarations in CSS precedence, which is!important.

In a CSS style sheet, a style with a!important declaration takes precedence, and its precedence goes beyond any style declaration in any way, including the style declared in the inline style property.

For example, the following code:

<style type= "Text/css" > p{color:red!important;}  </style> <p style= "Color:blue; "> This is a line of text </p>

This line of text still appears in the browser as a red font.

Therefore, the precedence of CSS style matching follows the following order:

(1)!important statement above all.

(2) The embedded style is the second.

(3) The style sheet declares the sort by the weight of the selector.

(4) Finally, according to the order of the browser execution style sheet, follow the "catch up" principle to match the style.

Of course, the last thing to emphasize is that if you don't set a style, the style of the parent node is automatically inherited.

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.