CSS Code Style

Reference Code Standard

Google’s CSS guide

The Code Guide also provides excellent guidance for developing consistent, flexible, and sustainable CSS.

Implementing the Standard

Many IDE’s provide formatting, linting and hinting support.

We recommend linting CSS with Stylelint . The stylelint-config-standard ruleset enforce the common stylistic conventions found within a handful of CSS style guides.

npm install stylelint stylelint-config-standard --save-dev
# or
yarn add stylelint stylelint-config-standard --dev

You should have a .stylelintrc file in your project’s root. Example:

{
  "extends": ["stylelint-config-standard"],
  "rules":
    {
      // Additional, per-project rules...
    },
}

You may find it useful to add a .styleintignore file to your project’s root so linting is not run on minified and other file types. Example:

node-modules/
*.min.css
*.html
*.svg