Skip to content

Dev.Coding Standard CSS

nothing edited this page Jul 15, 2013 · 6 revisions

Top CSS/HTML Standards

  • 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-

Note

Selected Rules

  • 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 {}, not clear {}. ?
  • 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 {}, not div.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. ? -> ?

Amended Rules

  • Use tabs for indentation: length of 4 spaces. ? | ?
  • Non-ASCII characters are forbidden, use encoded characters: font-family: '\5FAE\8F6F\96C5\9ED1', 'Microsoft Yahei';, not font-family: '微软雅黑', 'Microsoft Yahei';

Pi specific rules

  • Framework
  • Module
  • ...
Clone this wiki locally