CSS selector priority and weight issues "CSS core issues"

Source: Internet
Author: User

1.CSS Selector priority:!important > Inline style > ID >class and property selector > tag Selector > Wildcard selector Note: [Junior engineer Level]

2. The reason why there is priority issues, in the final analysis, these selectors have the right to heavy, the greater the weight value, the higher the priority! As shown below:

!important infinity[Positive Infinity]

Inline selector 1000[weights]

ID selector 100[Weight]

class| Property | pseudo-class selector 10[weight]

tag | pseudo element selector 1[weight]

wildcard character 0[weight]

The above weights satisfy the computational relationship, in mathematics, positive infinity plus 1 and positive infinity is the same, but in the computer, positive infinity plus 1 is more than positive infinity, that is, in the computer infinite is endless!

Need to note: here the 1000 and 100 and other numerical weights are not decimal, are 256 binary, so 1 and 2 is not the difference between 1, but the difference 256! "High-up knowledge points"

CSS selector priority and weight issues "CSS core issues"

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.