HTML <shadow> Tag

Beginner
5 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The <shadow> element was part of early Shadow DOM v0 (mainly Chrome). It acted as an insertion point so an older shadow tree could show through a newer one.

Study it only as web history. For encapsulation today, attach one Shadow DOM v1 root with attachShadow(), compose light DOM with <slot>, and see <template> for declarative shadow roots (shadowrootmode).

Obsolete & non-standard.

Never standardized in HTML. Shadow DOM v0 (including <shadow>) was removed from Chrome around version 73. Modern browsers do not compose nested trees through this tag.

Use instead.

One host → one shadow root via element.attachShadow({ mode: "open" }) (or "closed"), plus <slot> for projected content.

HTML Syntax

syntax.html
<shadow> …legacy insertion point…</shadow>

Both tags were used historically. Today the element is an unknown HTML tag — no Shadow DOM v0 behavior runs.

Attributes

<shadow> had no element-specific attributes. Global attributes never restored v0 composition:

AttributeDescriptionTry it
(none specific)No HTML attributes defined shadow-tree insertion behaviorTry it
id / classGlobals only — ignored for Shadow DOM composition todayLegacy only
Modern APIUse attachShadow({ mode }) instead of this elementTry it
<slot>v1 insertion points for light-DOM content (not the old <shadow> tag)Try it

Global Attributes

The <shadow> tag also supports the Global Attributes in HTML — they do not revive Shadow DOM v0.

Live Preview

Compare ignored legacy markup with a working Shadow DOM v1 demo.

Legacy mode shows plain unknown-element content. Modern mode attaches a real shadow root.

Preview
<shadow> is ignored for composition. Nested text may still appear as ordinary HTML.

Legacy — no Shadow DOM v0 insertion point.

HTML Examples

Short snippets for study. Use Try It Yourself for a live editor.

Example 1 — Legacy <shadow> Markup

Historical shape only. Modern browsers do not create a shadow insertion point.

HTML
<my-widget>
  <shadow>
    <p>Older shadow tree would have shown here (v0).</p>
  </shadow>
</my-widget>
Try It Yourself

How It Works

  1. v0 idea: place <shadow> where an older shadow tree should project.
  2. Only early Chrome implemented that model.
  3. Today: tags parse as unknown HTML; no nested-tree merge happens.
  4. Do not ship this pattern in new pages.

Example 2 — Modern attachShadow()

Attach one Shadow DOM v1 root to a host element with JavaScript.

HTML
<div id="host"></div>
<script>
  const host = document.getElementById("host");
  const root = host.attachShadow({ mode: "open" });
  root.innerHTML = "<p>Hello from Shadow DOM v1.</p>";
</script>
Try It Yourself

How It Works

  1. Pick a host (any element that may hold a shadow root).
  2. Call attachShadow({ mode: "open" }) once per host.
  3. Build the tree under the returned shadow root (innerHTML, DOM APIs, etc.).
  4. Page CSS outside the root does not style internal nodes by default (encapsulation).

Example 3 — Compose with <slot>

Project light-DOM children into the shadow tree — the v1 replacement for old insertion ideas.

HTML
<div id="card">
  <span slot="title">Sale</span>
  Weekend deal
</div>
<script>
  const host = document.getElementById("card");
  const root = host.attachShadow({ mode: "open" });
  root.innerHTML =
    "<strong><slot name=\"title\"></slot></strong> " +
    "<slot></slot>";
</script>
Try It Yourself

How It Works

  1. Light DOM stays as children of the host (here, title + text).
  2. Named <slot name="title"> pulls in the matching slot="title" child.
  3. Default <slot> receives remaining light-DOM content.
  4. This is v1 composition — not the removed <shadow> element.

Edge Cases & Pitfalls

Most confusion mixes the obsolete tag with modern Shadow DOM APIs.

obsolete

Never use in new pages

Validators and reviewers treat <shadow> as dead API. Rewrite to attachShadow + <slot>.

naming

Tag ≠ shadow root

A shadow root is created by the API (or declarative shadowrootmode). The <shadow> element was a separate v0 insertion point.

one root

One shadow root per host

Shadow DOM v1 does not nest multiple roots on the same host the way v0 explored. Call attachShadow once.

silent

Looks alive, does nothing special

Unknown elements still render children. That can hide a broken migration until you test encapsulation.

declarative

Prefer template shadowrootmode

For HTML-first shadow trees, use <template shadowrootmode="open"> — not <shadow>.

Browser Support

The <shadow> element is obsolete. Modern Shadow DOM uses attachShadow() and slots — not this tag.

✓ Obsolete element

<shadow>

Shadow DOM v0 (including HTMLShadowElement / <shadow>) was Chrome-only and removed around Chrome 73. Other engines never shipped the element. Use Shadow DOM v1 instead.

0% Modern support for &lt;shadow&gt;
Google Chrome Removed (~73)
Unsupported
Mozilla Firefox Never
Unsupported
Apple Safari Never
Unsupported
Microsoft Edge Never (Chromium: removed)
Unsupported
Opera Removed with Chromium
Unsupported
Samsung Internet Removed
Unsupported
<shadow> element Removed / unsupported

Bottom line: Do not use <shadow>. attachShadow() and <slot> are widely available for real encapsulation.

Key Takeaways

  • Status: <shadow> is obsolete Shadow DOM v0 — never use it.
  • Replace with: attachShadow() + <slot> (one root per host).
  • Declarative option: <template shadowrootmode> on modern engines.
  • Naming trap: the tag is not the same thing as a shadow root.

One line: skip <shadow>; learn attachShadow and slots for real encapsulation.

Default CSS Settings

Unknown elements like obsolete shadow typically display as inline. A simplified idea:

default.css
shadow {
  display: inline;
}

There is no special user-agent stylesheet for Shadow DOM v0 composition.

Frequently Asked Questions

In early Shadow DOM v0 (mainly Chrome), shadow acted as an insertion point so an older shadow tree could render inside a newer one. It was never part of the standardized HTML Living Standard.
No. Do not use it. Browsers removed Shadow DOM v0 years ago. Current engines treat shadow as an unknown element with no shadow-composition behavior.
Attach one Shadow DOM v1 root with element.attachShadow({ mode: "open" }) or "closed", and compose light DOM with slot elements. For markup-first trees, use a template with shadowrootmode.
No meaningful element-specific attributes. Global attributes never restored Shadow DOM v0 behavior in modern browsers.
No. attachShadow is the standard Shadow DOM v1 API. The old shadow tag was a v0 insertion point for nested older trees and has no direct replacement element.
Start with custom elements plus attachShadow and slots, and see the template tag for declarative shadow roots (shadowrootmode).

Next: small

Mark side comments and fine print with the HTML small element.

small tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful