CSS Development Specification

Source: Internet
Author: User

Although a simple CSS specification was compiled a long time ago, it was not very comprehensive and some details were not taken care of. Record a more detailed version to prepare for a rainy day.

Naming conventions
    1. the "mandatory" class is named with the lowercase letter + underscore format: class= "Class_name"
    2. "Mandatory" ID all use hump name law: id= "Idname"
    3. "suggested" name as far as possible to use English name, pinyin can also use but try to use abbreviation + English form.
Writing specifications"Mandatory"Add a space before the property value
. Main {     margin: 0;   }
"Mandatory"Leave a space on each side of the >, +, ~ Selector.
/**/{    padding: 10px;     Margin-left: 5px;} /*  */{    padding: 10px;     Margin-left: 5px;}
"Recommended"Minimize the level of selectors, preferably no more than level four"Recommended"Attributes should appear in a specific order to guarantee legibility of the recommended order: class, ID, name, data-*, SRC, for, type, href, value, Max-length, max, Min, pattern, placeholder , title, ALT, required, READONLY, disabled

Class is designed for highly reusable components, so it should be in the first place; the ID is more specific and should be used as sparingly as possible, so put it in the second place.

"Mandatory"A unit of length 0 in a style must be omitted
/** *{    padding: 0 5px;} /*  */{    padding: 0px 5px;}
"Recommended"Color values use lowercase as much as possible, and the same color values do not occur when the case is present. If not lowercase, you need to keep the same case in the same project.
/*very good*/. Success{Background-color:#aca;Color:#90ee90;}/*Good*/. Success{Background-color:#ACA;Color:#90EE90;}/* Bad*/. Success{Background-color:#ACA;Color:#90ee90;}
"Mandatory"The font name in the Font-family property should use the font's English

Common fonts correspond to family name: Arial (SimSun), Blackbody (Simhei), Microsoft Jache (Microsoft Yahei)

"Mandatory"Try to increase the reusability of the style and use the style as a generic class
. Left {    float: left;} . Right {    float: right;}
"Mandatory"If more than one class style is repeated, only the individual styles are different, you can separate the repeating style.
/*Good*/. Container. List. quan,.container. List. Friend{Display:Inline-block;width:4.5rem;Height:4.5rem;background-size:4.5rem Auto;}. Container. List. Quan{background-position:0 0;}. Container. List. Friend{background-position:0-4.5rem;}/* Bad*/. Container. List. Quan{Display:Inline-block;width:4.5rem;Height:4.5rem;background-size:4.5rem Auto;background-position:0 0;}. Container. List. Friend{Display:Inline-block;width:4.5rem;Height:4.5rem;background-size:4.5rem Auto;background-position:0-4.5rem;}

CSS Development Specification

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.