Scope a card
@scope (.card) {
:scope { padding: 1rem; border: 1px solid #cbd5e1; }
h2 { margin: 0 0 .5rem; }
}
The @scope at-rule limits where selectors apply. Put a root (and optional lower boundary) around rules so they only match inside that subtree.
@scope (.card) {
h2 { font-size: 1.1rem; }
img { border-radius: 8px; }
}@scope (.card) {
:scope { padding: 1rem; border: 1px solid #cbd5e1; }
h2 { margin: 0 0 .5rem; }
}@scope (.article) to (.widget) {
p { line-height: 1.6; }
}@scope is a modern CSS at-rule.
Check current browsers before relying on advanced behavior.
Bottom line: Use progressive enhancement. Keep a readable fallback when a browser ignores the at-rule.
Continue with @starting-style.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
3 people found this page helpful