<shadow>: The Shadow Root element
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
<shadow> HTML element—an obsolete part of the Web Components technology suite—was intended to be used as a shadow DOM insertion point. You might have used it if you have created multiple shadow roots under a shadow host. It is not useful in ordinary HTML.
This element includes the global attributes.
Here is a simple example of using the
<shadow> element. It is an HTML file with everything needed in it.
Note: This is an experimental technology. For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox.
<html lang="en"> <head></head> <body> <!-- This <div> will hold the shadow roots. --> <div> <!-- This heading will not be displayed --> <h4>My Original Heading</h4> </div> <script> // Get the <div> above with its content const origContent = document.querySelector("div"); // Create the first shadow root const shadowroot1 = origContent.createShadowRoot(); // Create the second shadow root const shadowroot2 = origContent.createShadowRoot(); // Insert something into the older shadow root shadowroot1.innerHTML = "<p>Older shadow root inserted by <shadow></p>"; // Insert into younger shadow root, including <shadow>. // The previous markup will not be displayed unless // <shadow> is used below. shadowroot2.innerHTML = "<shadow></shadow> <p>Younger shadow root, displayed because it is the youngest.</p>"; </script> </body> </html>
If you display this in a web browser it should look like the following.
This element is no longer defined by any specifications.
BCD tables only load in the browser