pseudo-class

:host — CSS reference

Inside a shadow stylesheet, matches that shadow tree’s host. It is not a general document selector and does not select arbitrary ancestors. The host can also receive styles from outside the shadow tree.

Formal Syntax & Structure

css syntaxcss
:host { display: block; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>#b {color:#202020}</style><body><div id="a" class="featured"><span id="slot" class="label">Assigned text <b id="nested">nested</b></span></div><div id="b">Outside</div><script>const root=a.attachShadow({mode:"open"});root.innerHTML="<style>:host {color:#006050}</style><slot></slot><p id=\"inside\" part=\"label\">Inside</p>";</script></body></html>
CSS Reference