Priority of CSS Selector

Source: Internet
Author: User
Today, I saw a blog post on Google Reader. After I asked several colleagues in the group, I found that I had always had a misunderstanding about CSS selector. It is said that foreigners Article I mentioned very early that CSS selector is a priority. Algorithm After being translated by some people in China, I misunderstood the meaning, as a result, many people think that the priority Calculation of CSS selector is to add all ID names, class names, and so on before comparison. I think one of them is me. Today I have realized the use of this CSS selector. I don't know whether my own "CSS things" mentioned it. If so, I guess it is probably the kind of incorrect understanding. Here, I am very sorry to all readers and friends. Here, I would like to thank Xiao fan for mentioning this option in his blog. Then, Xiao Zhi has the opportunity to understand and thank his colleagues in the group for sharing his ideas. This blog post is named "CSS selector priority". It focuses on the "11 classes and 1 ID" topic. Here we will not go into the details, you can click the link above to browse directly. Simply put, a div with the ID and class names is contained by ten Divs, and the style is :. a1. a2. a3. a4. a5. a6. a7. a8. a9. a10. a11 {color: red;} # B {color: green;} the HTML structure is long, as follows: the priority of CSS Selector

According to our previous understanding, the class in CSS is 10, and the ID is 100. Then we naturally thought that if we had 11 classes, it would be 110. In this way, it will be bigger than the ID. The final color should be red, but it is not. The final color is green, which is the ID color. At that time, I was very puzzled when I saw this, and then I was confused when I read the introduction in the article. Later, after being guided by my colleagues in the Group and my BS who were very serious to myself, I finally understood why. In fact, when I was reading some books, the numbers composed of 1 and 0 were actually only 1 and 0, not 1000, 100, 10, and 1. Reference the image of a small and traditional blog. As shown in the figure, when an ID is selected, it is 0, 1, 0, 0, and then the two IDs are 0, 2, 0, 0, and so on, this means that the second number from the left will increase progressively, but this number is only increasing. Similarly, the same applies to the use of class delimiters. Return to the problem of "11 classes and 1 ID" mentioned above. The calculation result is as follows: 0, 1, 0, 11 classes: 0, 0, 11, 0 extended reading: http://www.cssforest.org/blog/index.php? Id = 164 obviously, the ID style will certainly appear in this problem, and the class style will not appear. Keep in mind this lesson, spend more time reading articles from foreigners, and consolidate and better master basic knowledge. This year, my mind has been lost, so casual. Goals and directions are often forgotten by you. It is good for you to often experience such things. You can clearly see your own shortcomings and make up for them! Finally, I will say to myself: Continue to cheer up, Xiaozhi! Original: http://blog.linxz.de/about_css_selector/ this article link: http://www.blueidea.com/tech/web/2011/8388.asp 2012 Summer new Korean women's high waist sling sleeveless dress 2012 Summer new Korean fashion wild sling mesh dress such as Yi genuine 2012 spring and summer new cute wave point cake group put chiffon dress summer 2011 new Korean retro sweet bow low waist floral short sleeve dress waist original single cotton baiyiduo pinning shop 2012 Summer new Korean version of the season women's high waist sling sleeveless dress 2012 Summer new Korean style fashion wild sling mesh dress such as Yi genuine 2012 spring and summer new cute wave point cake group put chiffon dress summer dress 2011 new Korean retro sweet bow low waist floral short sleeve dress waist original single cotton white avilon home flagship store [3141 discount] sisters flower elegant lace gathered chest bcup bra [sisters flower underwear] fashion lace edging chest a cup bra 3105 [sister-in-law flower underwear] simple fashion side accept B cup bra 9023h2 Women's channel electrical appliances

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.