CSS Declaration Order
Related property declarations should be grouped together following the order:
- Positioning
- Box model
- Typographic
- Visual
Positioning comes first because it can remove an element from the normal flow of the document and override box model related styles. The box model comes next as it dictates a component’s dimensions and placement.
Everything else takes place inside the component or without impacting the previous two sections, and thus they come after.
See the other tutorial about setting up a Linter and a .sass-lint.yml file.
.declaration-order {
// Positioning
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100;
// Box-model
display: block;
float: right;
width: 100%;
height: 100px;
margin: 0;
padding: 0;
// Typography
font: normal 13px "Helvetica Neue", sans-serif;
line-height: 1.5;
color: #333;
text-align: center;
// Visual
background-color: #f5f5f5;
border: 1px solid #e5e5e5;
border-radius: 3px;
// Misc
opacity: 1;
}
More Stylesheets tutorials
-
SCSS Math Operators
Best practices for writing easy to maintain stylesheets.
-
SCSS Nesting
Best practices for writing easy to maintain stylesheets.
-
CSS Syntax
Best practices for writing easy to maintain stylesheets.
-
CSS Shorthand Notation
Best practices for writing easy to maintain stylesheets.
-
CSS Selectors
Best practices for writing easy to maintain stylesheets.
-
CSS Media Queries
Best practices for media queries inside your stylesheets.
-
CSS Class Names
Best practices for writing easy to maintain stylesheets.
-
Code Comments
Best practices for writing easy to maintain code.
-
SCSS Extend and Mixin
Best practices for writing easy to maintain stylesheets.