---
# System prepended metadata

title: 'Principles of writing consistent, idiomatic CSS'
tags: [CSS]

---

# Principles of writing consistent, idiomatic CSS

## Alphabetical Order
``` css
.foo {
  background: black;
  bottom: 0;
  color: white;
  font-weight: bold;
  font-size: 1.5em;
  height: 100px;
  overflow: hidden;
  position: absolute;
  right: 0;
  width: 100px;
}
```

## Type Ordering
``` css
.selector {
  /* Positioning */
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;

  /* Display & Box Model */
  display: inline-block;
  overflow: hidden;
  box-sizing: border-box;
  width: 100px;
  height: 100px;
  padding: 10px;
  border: 10px solid #333;
  margin: 10px;

  /* Color */
  background: #000;
  color: #fff
  
  /* Text */
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.4;
  text-align: right;

  /* Other */
  cursor: pointer;
}
```

## Resources
* [Sass Guidelines](https://sass-guidelin.es/#declaration-sorting)
* [Idiomatic CSS](https://github.com/necolas/idiomatic-css)
* [csscomb](https://github.com/csscomb/csscomb.js)
* [Concentric CSS](https://github.com/brandon-rhodes/Concentric-CSS)
* [Poll Results: How do you order your CSS properties? | CSS-Tricks](https://css-tricks.com/poll-results-how-do-you-order-your-css-properties/)

###### tags: `CSS`