| name | css-standards |
| description | Order CSS properties outside-in following Concentric-CSS. Use this skill whenever writing, editing, or reviewing CSS, SCSS, Less, styled-components, or Tailwind @apply blocks, including when adding a single property to an existing rule, and even when the user says nothing about property order. Also use when reviewing a diff that touches stylesheets. |
CSS Property Order
Order the properties in every rule outside-in, following Concentric-CSS: start with how the box is placed on the page, then work inward to its textual content. A reader learns where the element sits before learning what it looks like, so they can stop reading once they reach the part they came for.
Group Order
- box-sizing
- display, position (top/right/bottom/left)
- float, clear
- flex
- grid
- align, justify
- order, columns
- transform
- transition
- visibility, opacity, z-index
- margin
- outline
- border (width, style, radius, color, image, box-shadow)
- background, cursor
- padding
- width (min/max), height (min/max)
- overflow, resize
- list-style, table-layout
- animation
- vertical-align
- text (alignment, decoration, spacing)
- color
- font
- content, counters
- page breaks
For a property that is not listed, place it with the group it belongs to by function. gap sits with flex and grid, filter with transform, caret-color with color.
Example
Reorder an existing rule like this. Nothing is added or removed, only moved.
Before:
.box {
color: #333;
display: flex;
font-size: 1rem;
width: 100%;
border: 1px solid;
margin: 1rem;
padding: 0.5rem;
visibility: hidden;
}
After:
.box {
display: flex;
visibility: hidden;
margin: 1rem;
border: 1px solid;
padding: 0.5rem;
width: 100%;
color: #333;
font-size: 1rem;
}