CSS Coding Standards
Structure
Each selector should be on its own line, ending in either a comma or an opening curly brace.
Selectors
Use lowercase and separate words with hyphens when naming selectors. Avoid camelcase and underscores.
Property Ordering
Group like properties together, especially if you have a lot of them.
The baseline for ordering is:
- Display
- Positioning
- Box model
- Colors and Typography
- Other
Order Alphabetically
If you have a lot of properties in a group, order them alphabetically.
Values
- Use lowercase for hex colors.
- Use shorthand properties when possible.
- Use double quotes rather than single quotes except in font names.
- Font weights should be defined using numeric values (e.g. 400 instead of normal, 700 rather than bold).
Comments
Like PHPDoc, CSS comments should be used to describe the purpose of a block of CSS.
For Sections and Subsections
For inline: