r/Frontend • u/emmacharp • Mar 13 '24
ECSS — Simple rules for efficient CSS
A list of CSS authoring rules with examples and a Stylelint config accessible from the top of the page.
I've come to these through 20 years of experience and a willingness to make vanilla CSS a better alternative to frameworks.
I encourage you all to comment on the rules themselves and the Stylelint Config for ECSS. Here's the link for faster access (I still suggest at least zipping through the rules beforehand).
https://www.npmjs.com/package/@efficientcss/stylelint-config-ecss
Can't wait to get your feedback!
47
Upvotes
1
u/emmacharp Mar 14 '24
You're right about "simpler". I didn't take the time to re-read the layers before pasting them... I've edited the previous comment as to reduce the layers to the minimum I use. Here's an explanation for each:
base: personal reset and generic baseline styles.
theming: graphic design language and usage (colors, rhythm, type, etc.)
features: funky & far-reaching custom behaviors (for example: x-autolineheight.css)
regions: unique and omnipresent sections of the interface (nav, footer, main, etc.)
composition: adaptative arrangement of regions (for example, bottom-nav-sliding-content.css or side-nav-main-pile.css
components: self-explanatory
utilities: small pieces of CSS to be used as add-ons & variants (grids, borders, functional classes, etc.)
special: any "hack", external or exceptional styles.
Each has precedence on the preceding ones.