Optimization of CSS selectors (efficiency)

Source: Internet
Author: User
  1. ID selector (#myid)
  2. Class selector (. myclassname)
  3. Tag Selector (div,h1,p)
  4. Adjacent selector (h1+p)
  5. Sub-selector (ul > li)
  6. Descendant selector (Li a)
  7. Wildcard selector (*)
  8. Property selector (a[rel= "external"])
  9. Pseudo-Class selector (A:hover,li:nth-child)

Efficiency from high to low.

The browser reads selectors in the order from right to left ...

Ways to write high-efficiency options:

  1. Avoiding Universal Rules
  2. Do not tag names or class names before the ID selector
  3. Do not spike signatures before the class name selector
  4. Use a specific category whenever possible
  5. Avoid using descendant selectors
  6. A sub-selector should not be included in a label classification rule
  7. Problems with child selectors
  8. With related inheritance relationships
  9. Use the style sheet in the range

Optimization of CSS selectors (efficiency)

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.