CSS coding standards

Last updated on
17 August 2023

Note: Changes to Drupal coding standards are proposed and discussed in issues in the Coding Standards project.

To minimize friction when contributing to CSS, the front-end developers of the Drupal community have reached consensus about our coding standards for:

  • Formatting CSS code.
  • CSS architecture, including goals, pitfalls and best practices.
  • Grouping rulesets into files.

Despite our natural range of working styles and coding preferences, we value collaboration and ease of development, so we have attempted to explain our standards clearly in the following documents.

"Part of being a good steward to a successful project is realizing that writing code for yourself is a Bad Idea™. If thousands of people are using your code, then write your code for maximum clarity." - Idan Gazit

Acknowledgements

This guide is based upon the works, Principles of writing consistent, idiomatic CSS by Nicolas Gallagher and Scalable and Modular Architecture for CSS (SMACSS) by Jonathan Snook with a hat tip to Nicole Sullivan’s ground-breaking Object Oriented CSS.

Help improve this page

Page status: No known problems

You can: