brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: @layer lets a css reset lose to your styles whatever the specificity

Css
~/tips/tip-css-layer-order-cascade

@layer reset { a { color: inherit; } }

Groups rules into ordered layers so the cascade order beats selector specificity.

Specificity wars end when the order of whole groups of rules is declared up front.

@layer reset, base, components, utilities;
@layer reset { a { color: inherit; } }
@layer components { .nav a { color: #0645ad; } }

The first line fixes the order of the layers: later layers beat earlier ones, no matter how specific a selector inside is. A single a selector in utilities would therefore beat #nav .link a in reset. Importing third-party CSS into its own layer keeps it from overriding yours. One trap: rules outside any layer win over every layer, so unlayered legacy styles can overrule a carefully ordered setup.

Further reading: MDN: @layer

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link