Special nature of Selector

Source: Internet
Author: User

Source: proficient in CSS: advanced Web Standard Solutions

To calculate the rule's particularity, each selector is assigned a numerical value. Then, the values of each selector of the rule are combined to calculate the rule's particularity.

The specificity of selector is divided into component levels: A, B, C, and D.

    • If the style is intra-row style, a = 1.
    • B = the total number of ID selectors.
    • C = number of class, pseudo class, and attribute selector.
    • D = number of type selectors and pseudo element selectors.

Special Example

Selector

Special

10-based particularity

Style = "" 1, 0, 0 1000
# Wrapper # Content {} 0, 2, 0, 0 200
# Content. dateposted {} 0, 1, 0 110
Div # Content {} 0, 1, 1 101
# Content {} 0, 1, 0, 0 100
P. Comment. dateposted {} 0, 0, 2, 1 21
P. Comment {} 0, 0, 1, 1 11
Div P {} 0, 0, 0, 2 2
P {} 0, 0, 0, 1 1

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.