CSS specification-Typical errors

Source: Internet
Author: User



Selector usage that does not meet NEC specifications

. class{}

Do not use a no-category style as the primary selector, such selectors can only be used as descendant selectors, such as. m-xxx. class{}.
. M-xxx div{}

Do not use a label without semantics as a selector, which can cause a large area of pollution unless you can conclude that your selector will not contaminate the other species now or in the future.
. g-xxx. class{}

Do not use descendant selectors in page layouts, because this descendant selector may contaminate the elements inside.
. g-xxx. m-yyy{}.g-xxx. u-yyy{}

Do not use layouts to control modules or components, modules and components should be separate from the layout.
. m-xxx. f-xxx{}.m-xxx. s-xxx{}

Do not redefine or modify or add functional class selectors and skin class selectors that are already defined through modules or other classes.
. m-xxx. Class. class. class{}

Do not write the selector too lengthy, this will increase the file size and limit the selection of too small range, so that the tree structure too strict application scope is too limited, it is recommended that 3-4 of the length of the finished.

Selectors do not need to fully reflect the structure nesting order, but instead, they can contributors Jane.
. m-xxx. m-yyy. zzz{}

Do not leapfrog control, if. ZZZ is a descendant selector for. M-yyy, then it is not allowed. Selectors other than m-yyy control or modify. zzz.

You can use the. m-yyy extension to modify. zzz, such as. m-yyy-1. zzz{}.

Extension Class Usage Error

An extension class must be used at the same time as its base class for the same node.

Error: class= "g-xxx g-yyy-1" class= "m-xxx-1" class= "u-xxx u-yyy-1" class= "xxx-yyy".
Correct: class= "g-xxx g-xxx-1" class= "m-xxx m-xxx-1" class= "u-yyy u-yyy-1" class= "xxx xxx-yyy".

CSS specification-Typical errors

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.