Manual:Coding conventions/CSS

Whitespace

 * One selector per line
 * Opening braces for the CSS declaration block on the same line as the (last) selector
 * Indent each declaration with a tab
 * No space before the colon
 * One space between the colon and the value
 * a semi-colon after each declaration (including the last one)
 * Closing braces unindented back to the left
 * Annotation for CSSJanus and CSSMin should be on their own line, above the CSS declaration they're for.
 * An empty line between one CSS rule set and the next.

Quotes
In the  declaration, the   syntax is preferred to be used without quotes. They are not needed. The only case where it could cause problems is when an unescaped closing parenthesis occurs in the given path, but those should be URL-escaped.

CSS3
Always put newer versions after older versions in case of vendor prefixes, putting the standardized declaration at the end. See also http://css-tricks.com/ordering-css3-properties/.

And in the case of gradients, make sure to provide a good solid fallback color. And make sure that whatever content is displayed on top of the background does not depend on it being a gradient (depend, as in, should not become less readable or usable).

Naming
Name classes and IDs the same way: all lowercase and broken up by dashes. Use the  prefix to avoid conflicts with IDs generated by the wikitext parser to mark section headings

Some examples:

Less
Coming in MediaWiki 1.22, there is native support for LESS. Most of the Less syntax can be formatted using the CSS conventions:
 * Indent nested blocks with 1 tab (same as for indenting declarations inside CSS rules).
 * Don't space-align declarations values inside mixins (same as for CSS rules).
 * No spaces on the outside of the parameter lists in function invocations, mixin uses and mixin definitions (same as for  in CSS).

Example:

There's a few new concepts that don't map to CSS conventions, outlined below.

Structure

 * Separate nested css rules from the parent declarations by 1 empty line.

Import

 * The filename of an import statement should omit the  file extension.