Web Components

shadowrootmode="closed"

Creates a declarative shadow root that is not exposed by host.shadowRoot. Closed mode is encapsulation, not a security boundary; code with other references can still access the tree. On template in a supported host during HTML parsing; missing or invalid values do not create a declarative shadow root. Assigning this attribute to a template after parsing does not itself create a root.

Formal Syntax & Structure

html syntaxhtml
shadowrootmode="closed"

Parameters & Attributes

NameTypeDescription
shadowrootmodekeywordCreates a declarative shadow root that is not exposed by host.shadowRoot. Closed mode is encapsulation, not a security boundary; code with other references can still access the tree.

Working Example

Example Snippethtml
<div id="host">  <template shadowrootmode="closed">    <p>Shadow content</p>  </template></div>
HTML Reference