TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: ECSS – Simple rules for efficient CSS

43 pointsby emmacharpabout 1 year ago
A list of CSS authoring rules with examples and a Stylelint config accessible from the top of the page.<p>I&#x27;ve come to these through 20 years of experience and a willingness to make vanilla CSS a better alternative to frameworks.<p>I encourage you all to comment on the rules themselves and the Stylelint Config for ECSS. Here&#x27;s the link for faster access (I still suggest at least zipping through the rules beforehand).<p><a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@efficientcss&#x2F;stylelint-config-ecss" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;@efficientcss&#x2F;stylelint-config...</a>

6 comments

SkeuomorphicBeeabout 1 year ago
&gt;Use attribute selectors to convey unicity.<p>&gt; &#x2F;* Do *&#x2F;<p>&gt; [id=&quot;main&quot;] { max-width: 80ch; }<p>&gt; &#x2F;* Don&#x27;t *&#x2F;<p>&gt; #main { Max-width: 80ch; }<p>I strongly disagree with this kind of guideline. The id attribute has very good uses, and in those cases the hash syntax should be the preferred way.<p>The use of id in an attribute selector is such a bad choice that makes me question the whole document.
评论 #39698378 未加载
vancroftabout 1 year ago
This is a very interesting approach, and the rules and principles are very sensible. It&#x27;s nice to see something that tries to really use the platform and emphasize semantic HTML.<p>Of course, as with any convention-based, getting everyone to follow the rules might be difficult, although the stylelint-config helps.<p>It would be helpful to see an example of the ruleset applied to a large-ish solution. There are a lot of rules, so it&#x27;s kind of hard to imagine what it would look actually look like in the css.<p>Could you elaborate a little on what you mean by “just-in-time” rulesets and how rule 22 (&quot;Component styling should only be served with live components.&quot;) works in practice? Are you referring to web components?
评论 #39713995 未加载
pwnOrbitalsabout 1 year ago
ECSS also means &quot;European Consortium for Space Standardization&quot;. They edit the standards for all fields within space engineering :)
评论 #39697475 未加载
morbicerabout 1 year ago
Eh, I dislike Tailwind but this doesn&#x27;t sound like it will hold water in the long run.<p>Why the hell does a rule talk about consistent padding and then not use css variable? A class name .card is a sure thing to conflict somewhere. Typography inheritance is another good way how to introduce hard to debug bugs. Global scope css - ewww (use only absolute minimum necessary).<p>Please use css-in-js, Tailwind, shadow dom or at the bare minimum css modules. Friends and future you will thank you.<p>But hey, maybe they are building some blog. I live in the apps world.<p>Also some rules are valid like the one about not using margin on the component itself.
评论 #39709886 未加载
adr1anabout 1 year ago
A pre-commit script would be nice and easy entry (at least for me)
评论 #39697904 未加载
midzerabout 1 year ago
Pretty solid approach, been a good read.<p>CSS performance is underrated as well.
评论 #39698055 未加载