So many great encapsulation strategies, so little time!

<style>
p {
color: blue;
font-size: 2rem;
}
</style>

<my-el>
<style>
@Scope {
:scope {
&, * {
all: revert-layer;
color: red;
}
}
}
</style>
<p>This text is red & small!</p>
</my-el>

<my-el>
<template shadowrootmode="open">
<style>
* {
color: red;
}
</style>
<p>This text is red & small!</p>
</template>
</my-el>

https://codepen.io/Westbrook/pen/vYMgOyZ?editors=1000

#CSSScope #shadowDOM #declarativeShadowDOM #webDev

Encapsulation Part!

...

It appears Webkit has enabled @scope support in their stable branch. It may appear in the next version of tech preview...? 👀

https://github.com/WebKit/WebKit/pull/21435

#css #CSSScope

[CSS] Activate the CSS @scope feature in stable by mdubet · Pull Request #21435 · WebKit/WebKit

b7c1e98 [CSS] Activate the CSS @scope feature in stable rdar://119261250 Reviewed by Tim Nguyen. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Canonical link: https://commits.webk...

GitHub
CSS @scope | 12 Days of Web

The new `@scope` rule is here! It's a better way to keep our component styles contained – without relying on third-party tools or extreme naming conventions.

#Development #Introductions
Limit the reach of your CSS selectors with ‘@Scope’ · A way to select elements only within a subtree of your DOM https://ilo.im/15b1hq

_____
#WebDev #Frontend #CSS #CssScope #DOM #Demos

Limit the reach of your selectors with the CSS `@scope` at-rule - Chrome for Developers

Learn how to use @scope to select elements only within a limited subtree of your DOM.

Chrome for Developers

#Development #Reviews
Scope vs. Shadow DOM · A justification for a much-needed CSS feature https://ilo.im/14xlyj

_____
#WebDev #Frontend #CssScope #ShadowDOM #WebComponents #HTML #CSS #JavaScript

Scope vs Shadow DOM

When CSS grid first arrived, there were a lot of people saying, “Why do we need this? We already have flexbox!” I’m getting very much the same vibe now with @sc

#Development #Previews
A quick introduction to CSS @Scope · An upcoming way to scope the reach of your CSS selectors https://ilo.im/14wr7j

_____
#WebDev #Frontend #CSS #CssCascade #CssScope #Chrome

A quick introduction to CSS @scope

An introductory thread to CSS @scope.

Bram.us