{
    "content": "<h1><a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a><\/h1><p>In the architecture of <a href=\"..\/Web-Components\/\">Web-Components<\/a>, a <a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a> is a standard <a href=\"..\/Document-Object-Model\/\">Document-Object-Model<\/a> node that serves as the mounting point for a <a href=\"..\/Shadow-Root\/\">Shadow-Root<\/a>. It acts as the bridge between the light DOM—the regular DOM tree of the page—and the encapsulated <a href=\"..\/Shadow-DOM\/\">Shadow-DOM<\/a> tree. This mechanism allows developers to attach a hidden, separate DOM to an element, providing a robust way to manage <a href=\"..\/Encapsulation\/\">Encapsulation<\/a> in web applications.<\/p><h2>Technical Implementation<\/h2><p>An element becomes a <a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a> when the <code>Element.attachShadow()<\/code> method is called upon it via <a href=\"..\/JavaScript\/\">JavaScript<\/a>. Once attached, the host's children are no longer rendered; instead, the browser renders the contents of the <a href=\"..\/Shadow-Root\/\">Shadow-Root<\/a>. However, the <a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a> itself remains a part of the light DOM, meaning it can be targeted by global <a href=\"..\/CSS\/\">CSS<\/a> selectors and scripts, while its internal shadow tree remains protected from external interference.<\/p><h2>Styling and Interaction<\/h2><p>One of the most powerful features of the <a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a> is its ability to be styled from the inside using the <code>:host<\/code> pseudo-class. This allows a component to define its own exterior appearance while still allowing users of the component to override those styles from the outside. Detailed specifications regarding these interactions can be found on the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Web_components\/Using_shadow_DOM\">MDN Web Docs<\/a> and the official <a href=\"https:\/\/dom.spec.whatwg.org\/#shadow-trees\">W3C DOM Specification<\/a>. The <a href=\"..\/Shadow-Host\/\">Shadow-Host<\/a> is also responsible for event retargeting, ensuring that events bubbling up from the shadow tree appear to originate from the host itself to maintain the abstraction of the component.<\/p><ul><li><a href=\"..\/Shadow-Root\/\">Shadow-Root<\/a><\/li><li><a href=\"..\/Custom-Elements\/\">Custom-Elements<\/a><\/li><li><a href=\"..\/CSS-Scoping\/\">CSS-Scoping<\/a><\/li><li><a href=\"..\/HTML-Templates\/\">HTML-Templates<\/a><\/li><\/ul>",
    "tags": [
        "shadow-host",
        "shadow-dom",
        "web-components",
        "html5",
        "encapsulation",
        "css-scoping",
        "javascript",
        "dom-api",
        "front-end-development",
        "custom-elements"
    ]
}