CSS Selector Performance differences

Source: Internet
Author: User

(1) The selector is a rule match from right to left.

(2) The execution efficiency of the selector is sorted from high to Low:

ID selector; class selector; tag Selector;

Adjacent selector +; Sub-selector >; descendant selector;

Wildcard selector *; property selector []; pseudo-class selector :;

(3) How to improve selector performance:

1) Avoid using a wildcard selector;

2) Avoid using the tag or class selector to limit the ID selector;

3) Avoid using tags to restrict class selectors;

4) Avoid using multi-layer tag selectors. Replace with class selector, reduce CSS search;

5) Avoid using sub-selectors;

6) use of inheritance;

CSS Selector Performance differences

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.