#CSSScope

westbrookwestbrook
2024-03-18

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>

codepen.io/Westbrook/pen/vYMgO

2023-12-20

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

github.com/WebKit/WebKit/pull/

#css #CSSScope

Inautiloinautilo
2023-12-16


CSS @Scope · The novel way to keep component styles contained ilo.im/15xfo1

_____

Inautiloinautilo
2023-10-05


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

_____

Inautiloinautilo
2023-08-28


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

_____

Inautiloinautilo
2023-08-25


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

_____

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst