HTML <shadow> Tag

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 2 Examples
Web Components

What You’ll Learn

The <shadow> tag was part of an experimental Shadow DOM feature. This guide explains its deprecated status, historical syntax, and the modern attachShadow() API beginners should use instead.

01

History

Early Shadow DOM.

02

Deprecated

Do not use.

03

Syntax

Historical only.

04

Encapsulation

Isolated styles.

05

attachShadow

Modern API.

06

Migration

Best practices.

What Is the <shadow> Tag?

The <shadow> tag was introduced to help developers create encapsulated DOM trees (shadow DOMs) within a web component. The shadow DOM allows better modularity and style encapsulation in web development.

🚫
Deprecated — Not for Modern HTML

The <shadow> tag is deprecated and should not be used. It was part of an early Shadow DOM implementation replaced by the JavaScript Shadow DOM API.

🚫 Deprecated Status

The <shadow> tag is now deprecated and should not be used in modern web development. It was part of an early implementation of the Shadow DOM specification but has been replaced by more robust and standardized methods.

Do not use <shadow> in new projects. Modern browsers do not treat this element as a Shadow DOM insertion point. Use attachShadow() on custom elements instead.

📝 Syntax

The historical syntax encapsulated content that was intended to be part of the shadow DOM:

index.html
<shadow>
  <!-- Shadow DOM content here -->
</shadow>

Since the tag is deprecated, this syntax should be avoided in favor of the Shadow DOM API shown in the Alternatives section.

Historical Use Inside Custom Elements

historical-shadow.html
<my-element>
  <shadow>
    <style>
      p { color: red; }
    </style>
    <p>This is shadow DOM content.</p>
  </shadow>
</my-element>

⚡ Quick Reference

TopicDetailsStatus
<shadow> elementDeclarative Shadow DOM (old)Deprecated
Modern APIelement.attachShadow()Use this
Custom elementscustomElements.define()Web Components
EncapsulationStyles scoped to shadow rootSupported via API
Tag attributesNone meaningfulN/A
Browser support<shadow> element0% modern

⚖️ <shadow> vs attachShadow()

ApproachHow it worksUse today?
<shadow> tagHTML element inside custom element markupNo — deprecated
attachShadow()JavaScript API on HTMLElementYes — standard
Declarative Shadow DOM<template shadowroot> in HTMLYes — modern declarative option

🧰 Attributes

The <shadow> tag had limited attribute support, focusing primarily on encapsulating content rather than adding functionality through attributes.

None Deprecated

No tag-specific attributes were defined for meaningful behavior in modern HTML.

<shadow>...</shadow>
Global attrs Ignored

Even global attributes like class or id have no practical effect on deprecated shadow insertion.

Not recommended

Examples Gallery

Compare the historical shadow syntax with the modern Shadow DOM API you should use in real projects.

👀 Live Preview

Modern Shadow DOM via attachShadow() (the working approach):

📚 Common Use Cases

When <shadow> was in use, it was employed within custom elements to encapsulate styles and scripts, preventing them from affecting the global DOM.

Historical Encapsulation

Intended use inside a custom element with scoped styles. This no longer works in modern browsers:

index.html
<my-element>
  <shadow>
    <style>
      p { color: red; }
    </style>
    <p>This is shadow DOM content.</p>
  </shadow>
</my-element>
Try It Yourself

Alternatives — Shadow DOM API

The current standard is the Shadow DOM API, part of the Web Components suite. Create a shadow root with JavaScript:

index.html
<my-element></my-element>

<script>
  class MyElement extends HTMLElement {
    constructor() {
      super();
      const shadow = this.attachShadow({ mode: 'open' });
      shadow.innerHTML = \`
        <style>
          p { color: red; }
        </style>
        <p>This is shadow DOM content.</p>
      \`;
    }
  }
  customElements.define('my-element', MyElement);
</script>
Try It Yourself

♿ Accessibility

  • Do not use deprecated shadow markup — It provides no encapsulation and may confuse maintainers.
  • Shadow DOM and ARIA — When using attachShadow(), ensure interactive elements inside shadow roots remain keyboard accessible.
  • Focus management — Custom elements should not trap focus unless building intentional modal UI.
  • Expose meaningful names — Use accessible labels on controls rendered inside shadow DOM.

🧠 How Shadow DOM Works Today

1

Define custom element

Create a class extending HTMLElement and register it.

Register
2

attachShadow()

Call attachShadow({ mode: 'open' }) in the constructor.

Encapsulate
3

Inject shadow content

Set shadowRoot.innerHTML with scoped styles and markup.

Render
=

Isolated component UI

Styles and DOM inside the shadow root do not leak to the rest of the page.

Browser Support

The <shadow> HTML element is deprecated with 0% modern support. The Shadow DOM JavaScript API (attachShadow) is widely supported in all modern browsers.

🚫 Deprecated · HTML Element

Do not use the shadow tag

The <shadow> element was removed from the standard. Use attachShadow() instead.

0% <shadow> element
Google Chrome <shadow> not supported
Not supported
Mozilla Firefox <shadow> not supported
Not supported
Apple Safari <shadow> not supported
Not supported
Microsoft Edge <shadow> not supported
Not supported
Internet Explorer Never standardized
Not supported
Opera <shadow> not supported
Not supported
<shadow> HTML element 0% — deprecated

Note: attachShadow() API has ~97% global support. Only the deprecated <shadow> element is unsupported.

Conclusion

While the <shadow> tag played a role in early Shadow DOM experimentation, it is no longer relevant in modern web development. Developers should use the Shadow DOM API to achieve encapsulation and modularity in web components.

Understanding the history of such tags helps appreciate the evolution of web standards and encourages the adoption of best practices.

💡 Best Practices

Given the deprecated status of the <shadow> tag, avoid using it altogether. Adopt the modern Shadow DOM API for encapsulated DOM structures.

✅ Do

  • Use attachShadow() in custom element constructors
  • Register components with customElements.define()
  • Scope styles inside the shadow root
  • Consider declarative Shadow DOM (shadowroot) for SSR

❌ Don’t

  • Use the deprecated <shadow> HTML element
  • Assume old shadow markup still encapsulates content
  • Mix global styles expecting them to pierce shadow DOM
  • Copy legacy Web Components tutorials without checking APIs

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <shadow>

Bookmark these so you never use deprecated Shadow DOM markup.

6
Core concepts
📜 02

History

Early experiment.

Context
03

attachShadow

Modern API.

Alternative
🔒 04

Encapsulation

Scoped styles.

Purpose
🧩 05

Web Components

Custom elements.

Ecosystem
🔴 06

0% Support

Element dead.

Compatibility

❓ Frequently Asked Questions

Historically it was meant for declarative Shadow DOM inside custom elements. It is now deprecated and unsupported.
No. Use attachShadow() on custom elements instead of the shadow HTML element.
Call this.attachShadow({ mode: 'open' }) in a custom element and set shadowRoot.innerHTML.
No meaningful tag-specific attributes. It only wrapped content in early experiments.
The <shadow> element has 0% modern support. The Shadow DOM JavaScript API is widely supported.

Use the Shadow DOM API

Skip deprecated <shadow> markup. Practice attachShadow() in the Try It editor.

Try attachShadow() →

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.

6 people found this page helpful