Css WRITING PRINCIPLES

Source: Internet
Author: User

1.css selector the compiling method of css selector determines the number of matches that must be executed by the browser. Some Types of css selector will cause the browser to try more matches, therefore, the overhead is higher than the simple selector. This type of identifier is simple and efficient. It is used to match unique elements on a page. # Id {} class selector. className {} type selector tagName {} adjacent sibling selector H1 + # toc {} subselector # toc> li {} descendant selector # toc A {} wildcard selector * {} attribute selector [href = "# index"] {} pseudo class and pseudo element: hover {} key to efficient css selector 1) rightmost priority in fact, css selector matches from right to left. 2) Write efficient css delimiters to avoid using wildcard rules: only ID and class delimiters are used instead of ID delimiters: do not apply any other delimiters to the left of the ID selector. Do not use a specific tag to restrict class delimiters. Instead, expand the class names based on the actual situation. The more specific the rule, the better. Avoid using the descendant selector. Avoid using tags as subselector. Rely on inheritance to carefully check the usage of subselector.

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.