pseudo-element

::slotted() — CSS reference

Inside shadow CSS, targets elements assigned to a slot and matching a compound selector. It does not select arbitrary descendants of assigned elements or bare text nodes. Inherited properties may still reach descendants.

Formal Syntax & Structure

css syntaxcss
::slotted(.label) { color: teal; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>
</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>::slotted(.label) {background-color:#eaf5ef}</style><slot></slot><p id=\"inside\" part=\"label\">Inside</p>";</script></body></html>
CSS Reference