CSS Coding Standards and Guidelines

In this tutorial i will let you know best practices of css, some coding standard need to define to write beautiful and usable css class.This is very useful for web designer.

I have list down all factor which create better CSS coding style for css developer as well as css reader.These are basic points for css developer which need to keep in mind when you are writing CSS style.These factors will effect css code quality and reusability.

CSS Coding Standards

File Formatting

CSS filenames must be named using underscores (_) to demarcate new words

Naming Conventions

Separate words in CSS selectors should be demarcated with hyphens (e.g. .main-container).

Coding Style

* The unit of indentation is four spaces
* Selectors should be followed by one space, with the opening brace on the same line
* Properties should have one space after the colon
* Closing braces should be on a new line
* A metric value of 0 should be represented as 0 rather than 0px, 0em, etc.
* Textual representations of colors should be avoided. Use #fff over white
* Short representations of colors should be used if possible. Use #fff over #ffffff
* Lowercase letters should be used for almost every character in a CSS document. The only exception might be selector names and filenames. Otherwise, use lowercase letters for selectors, properties, values, and colors.

[code type=css]
.selector {
color: #000;

Multiple selectors should be entered on separate lines:

[code type=css]
.selector-3 {
display: block;