CSS Instance tutorial: CSS Selector priority

Source: Internet
Author: User
Tags numeric value

Article Introduction: 11 class with an ID "who has a high priority problem."

Last Friday, before work, our beloved 33 adults also discussed in the group about "11 classes and an ID" who has high priority problem ~_~!


Guess

01 <! DOCTYPE html>
02
03
04 <meta charset= "Utf-8" >
05 <style type= "Text/css" >
06 body{font-family: "Microsoft Yahei";}
07 . A1. a2 A3 A4 A5. a6 A7. A8.)
08 #b {color:green;}
09 </style>
10
11
12 <body>
13 <div class= "A1" >
14 <div class= "A2" >
15 <div class= "A3" >
16 <div class= "A4" >
17 <div class= "A5" >
18 <div class= "A6" >
19 <div class= "A7" >
20 <div class= "A8" >
21st <div class= "A9" >
22 <div class= "A10" >
23 <div class= "A11" id= "B" >
24 Priority of CSS Selector
25 </div>
26 </div>
27 </div>
28 </div>
29 </div>
30 </div>
31 </div>
32 </div>
33 </div>
34 </div>
35 </div>
36 </body>
37

The answer is clearly what you see, and why it's hard to tell.

Today, I suddenly think of proficient in CSS to speak about the particularity of the CSS calculation, the original is purple ...

All selector are assigned a numeric value (including inline), and all selector values are added to the final priority. However, the calculation is not a full 10 forward calculation, but instead of a higher cardinality is not specified. Ensure that the high level of selector (ID) is not exceeded by those 11 or more low-level selector combinations.
the particularity of the selector is divided into four grades: A,b,c,d can take a as the highest digit and so on.

    • If the style is inline a=1
    • B is the total number of IDs
    • C is class, Pseudo-class, and attribute selectors total

Come to this table:



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.