Skip to content

Coding Standards—CSS

Reuben L. Lillie edited this page Jul 5, 2019 · 1 revision

Cascading Style Sheets

CSS is the standard language for styling web pages. Together with Hypertext Markup Language (HTML) and JavaScript (JS), it forms the core of the web.

Learn more about CSS from the Mozilla Developer Network.

Structure

Write modular, descriptive, utility-first CSS.

As much as possible, list rules in DOM order.

Avoid using multiple selectors for single rule. If you must use multiple selectors, however, then place selectors on separate lines and list them alphabetically according to specifity (i.e., type, then class, then id).

Indent property: value; declarations with four spaces, not tabs.

Put a colon followed by a single space between property and value, followed by a semicolon.

element,
.class-selector,
#id_selector {
    property: value;
}
Clone this wiki locally