concept
encapsulation-context — CSS reference
When declarations compete across encapsulation contexts, outer normal rules take precedence over inner normal rules, whereas inner important rules win over outer important rules. This lets a component offer overridable defaults while retaining critical internal constraints. Context priority is evaluated before selector specificity.
Formal Syntax & Structure
css syntaxcss
/* document */ .widget { color: teal; }/* shadow stylesheet */ :host { color: red; }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>.widget {color:#006050} #b {color:#802020!important}</style><body><div id="a" class="widget">A</div><div id="b" class="widget">B</div><script>for (const [id,css] of [["a",":host{color:#802020}"],["b",":host{color:#006050!important}"]]) {document.getElementById(id).attachShadow({mode:"open"}).innerHTML="<style>"+css+"</style><slot></slot>";}</script></body></html>