css/Priority level

Source: Internet
Author: User

Precedence of CSS

The so-called CSS precedence refers to the order in which CSS styles are parsed in the browser.

The particularity of the style sheet describes the relative weights of the different rules, and its basic rules are:

1 The weights of the inline style sheet are highest style= ""------------1000;

2 The number of ID attributes in the statistics selector. #id--------------100

3 Number of class attributes in the statistics selector: class-------------10

4 the number of HTML tag names in the statistics selector. P---------------1

By adding the number of strings to bits by these rules, the final weight is obtained, and then the comparison is based on the left-to-right order.

1. The style priority in the text is 1,0,0,0, so it is always higher than the external definition.

2, there is!important declaration of the rules above all.

3. If the!important declares a conflict, the priority is compared.

4, if the priority is the same, according to the order in the source code to decide, later on the home.

5. The style obtained by inheritance has no specificity calculation, it is below all other rules (such as the rules defined by global selectors *).

css/Priority level

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.