-
Notifications
You must be signed in to change notification settings - Fork 114
Dev.Coding Standard CSS
nothing edited this page Jul 15, 2013
·
6 revisions
- All Pi Engine specific CSS class/ID names must be prefixed with
pi-
- All module specific CSS class/ID names are highly suggested to be prefixed with module identifier, for instance
article-
- All CSS class/ID names for JavaScript are highly suggested to be prefixed with
pi-js-
or<module>-js-
- Refer to Google HTML/CSS Coding Standard for details.
- Refer to more strict practices suggested by @krisxoofoo.
- Omit the protocol from embedded resources:
background: url(//www.google.com/images/example);
? - Remove trailing white spaces. ?
- Use functional or generic names, not presentational:
#login {}
,.video{}
, not.button-green {}
, notclear {}
. ? - Use ID/class names that are as short as possible but as long as necessary:
#nav {}
,.author {}
, not#navigation
, not.atr {}
. ? - Avoid unnecessary ancestor selectors:
.error {}
, notdiv.error {}
? - Omit unit specification after “0” values:
padding: 0;
. ? - Use namespace with Pi generic CSS and application-specific prefix:
pi-header {}
,.article-body {}
? - Separate ID/class name words by a hyphen:
.demo-image {}
? - Alphabetize declarations. ?
- Use a semicolon after every declaration. ?
- Separate selectors and declarations by new lines, use a space between the last selector and the declaration block. ? ?
h1,
h2,
h3 {
font-weight: normal;
line-height: 1.2;
}
- Always put a blank line (two line breaks) between rules. ?
- Use single ('') rather than double ("") quotation marks for attribute/property values. Do not use quotation marks in url(). ?
- Group style sheet sections together by using comments. Separate sections with new lines. ?
- Always use a single space between property and value. ?
- Abandoned: Indent by 2 spaces at a time. ? -> ?
- Use tabs for indentation: length of 4 spaces. ? | ?
- Non-ASCII characters are forbidden, use encoded characters:
font-family: '\5FAE\8F6F\96C5\9ED1', 'Microsoft Yahei';
, notfont-family: '微软雅黑', 'Microsoft Yahei';
- Framework
- Module
- ...