completefrontend
Open lab My progress
THE WEB COMPONENTS FIELD GUIDE

Web components in today's browsers

Web components browser support, part by part: what works in every browser, what's new since 2023, the removed APIs old tutorials use, and what needs care.

By the end, you can
  • 01
    Read the support for each partTell which parts of web components are Baseline, and check any part in your own browser with one line of code.
  • 02
    Know what's new and what's goneName what arrived from 2023 to 2026, and what to write today in place of each removed name.
  • 03
    Use the newest parts with careSpot the parts that work in only some browsers, and date a tutorial by the names it uses.

Do web components work in every browser?

Ravi looks after the website of Leaf and Kettle, a small tea shop. He wants a label for each tea, like the tea label you made in the last lesson. He finds a tutorial on custom elements, copies its code, and runs it. The browser stops with an error. Is his browser too old? Do web components work at all?

Yes, they do. Custom elements, shadow DOM, templates, and slots work in every major browser, and have since January 2020. The problem was the tutorial. It used a name that browsers removed years ago.

Here is the code Ravi copied. Press Edit & run to see the error for yourself:

Ravi's label, from an old tutorial (an error on purpose)Pop out in the code editor (opens in a new tab)JavaScript
const proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function () {
  this.textContent = "Green tea: brew for 3 minutes";
};
document.registerElement("tea-label", { prototype: proto });
  • Line 1 makes an object that starts with everything an HTML element has.
  • Lines 2 to 4 give it a method called createdCallback. It sets the label's text.
  • Line 5 tries to register the tag with document.registerElement().

The browser stops at line 5: TypeError: document.registerElement is not a function. This code comes from an early draft of web components. Only Chrome ever had it, and Chrome removed it in Chrome 80, in February 2020.

Here is the same label, written the way every browser understands it today:

The same label, with today's namesPop out in the code editor (opens in a new tab)HTML
<tea-label>Green tea</tea-label> <script>  class TeaLabel extends HTMLElement {    connectedCallback() {      this.textContent = "Green tea: brew for 3 minutes";    }  }  customElements.define("tea-label", TeaLabel);</script>
ResultLoading…
  • Line 1 puts the tag on the page, with Green tea inside.
  • Line 4 makes a class that extends HTMLElement.
  • Lines 5 to 7 are connectedCallback(). The browser calls it when the tag joins the page, and it sets the text.
  • Line 9 registers the tag with customElements.define().

The result shows Green tea: brew for 3 minutes. Chrome, Edge, Firefox, and Safari all show the same.

Real-life analogyAn old street map

You find an old map of your town in a drawer. It shows a bridge over the river. You walk there, and the bridge is gone. It was taken down years ago, and a new one stands a little way along. The map wasn't wrong. It was just old.

In real life: The old map
In JavaScript: An old tutorial
In real life: The bridge that was taken down
In JavaScript: A removed name, like document.registerElement()
In real life: Reaching the river with no bridge
In JavaScript: TypeError: document.registerElement is not a function
In real life: The new bridge a little way along
In JavaScript: Today's name, customElements.define()

So the real question has two parts. Which parts work where? And which names are current? This picture puts every part in this lesson on one of three shelves:

Web components today, on three shelves. Works in every browser: custom elements, shadow DOM, slots, templates, shadowrootmode, ElementInternals, scoped registry. Works in some browsers: is="", Reference Target, CSS modules, moveBefore(). Removed: registerElement(), createShadowRoot(), HTML Imports, /deep/. The removed names are crossed out.Works in every browsercustom elementsshadow DOMslots, templatesshadowrootmodeElementInternalsscoped registryWorks in some browsersis=""Reference TargetCSS modulesmoveBefore()RemovedregisterElement()createShadowRoot()HTML Imports/deep/
Most parts of web components work in every browser. A few newer parts work in only some. The crossed-out names are gone from every browser, but old tutorials still use them.
  • Works in every browser: the core parts, and newer ones that arrived from 2023 to 2026.
  • Works in some browsers: four newer parts. You can use them, with a plan for the browsers that lack them.
  • Removed: names from early drafts. Old tutorials still use them.
The main idea

Web components work in every major browser. Custom elements, shadow DOM, templates, and slots have worked everywhere since January 2020, and newer parts keep arriving. When old code fails, look at its names. Some were removed, and today's browsers use new ones.

Web components browser support, part by part

"It works in every browser" is a little vague. Which browsers? From which version? Web developers use one shared label for this. It's called Baseline.

What Baseline means

Baseline is a label for web features. The WebDX Community Group decides it. That group is part of the W3C, one of the groups that write web standards. Baseline looks at the core browsers: Chrome, Edge, Firefox, and Safari, on computers and on phones. Each feature gets one of three labels:

  • Limited availability: at least one core browser doesn't have it yet.
  • Newly available: the newest version of every core browser has it.
  • Widely available: it has been newly available for 30 months. Most sites can now use it without worry.
Real-life analogyA new kind of bank card

Your bank sends you a new kind of card. At first, only some shops can read it. Then one day, every big chain has the new reader. But a few of their counters still have old ones. A few years later, nearly every counter has been changed. Now you can pay with the card almost anywhere.

In real life: Only some shops can read the card
In JavaScript: Limited availability: some browsers don't have it
In real life: Every big chain has the new reader
In JavaScript: Newly available: the newest version of every core browser has it
In real life: Some counters still have old readers
In JavaScript: People still use older browser versions
In real life: A few years on, nearly every counter has the new reader
In JavaScript: Widely available: 30 months later

Here is how one part moved through the three labels. It's declarative shadow DOM, which you'll meet in the next section:

Declarative shadow DOM's road to Baseline, on a timeline from 2023 to 2026. Chrome 111 and Safari 16.4 shipped it in March 2023: limited availability. Firefox 123 shipped it in February 2024: newly available. Thirty months later, in August 2026: widely available.Chrome 111 and Safari 16.4Firefox 12330 months laterlimitednewly availablewidely2023202420252026
Declarative shadow DOM became newly available when Firefox 123 shipped it, in February 2024. Thirty months later, in August 2026, it became widely available.

Chrome and Safari shipped it in March 2023. Firefox shipped it in February 2024, so it became newly available. Thirty months later, in August 2026, it became widely available. For a widely available part, you can usually skip any backup plan. For a newer part, think about who visits your site first.

Browser support for every part

Here is every part this lesson covers. Each number is the first version of that browser with the part. "No." means no version has it yet. The numbers come from MDN's browser compatibility data, and the labels from Baseline.

Web components browser support, part by part
PartChrome and EdgeFirefoxSafariBaseline
Custom elements, customElements.define()546310.1Widely available since July 2022.
Shadow DOM, attachShadow()536310Widely available since July 2022.
Declarative shadow DOM, shadowrootmode11112316.4Widely available since August 2026.
Form-associated custom elements, setFormValue()779816.4Widely available since September 2025.
Constructable style sheets, new CSSStyleSheet()7310116.4Widely available since September 2025.
Custom states, :state()12512617.4Widely available since November 2026.
Turning an element back into HTML, getHTML()12512818Newly available since September 2024.
Scoped registries, new CustomElementRegistry()14615926Newly available since October 2026.
Customized built-in elements, is=""6763No.Limited availability.
Moving without a reset, moveBefore()133144No.Limited availability.
CSS module scripts, with { type: "css" }123147No.Limited availability.
Reference Target, referenceTarget152Behind a setting.Behind a setting.Limited availability.

Read the top rows first. Custom elements and shadow DOM have been widely available since July 2022. Declarative shadow DOM, form-associated elements, constructable style sheets, and custom states joined them later. getHTML() and scoped registries are newly available. The four rows at the bottom still say "Limited availability". A section below covers those four.

Check your own browser

A table tells you about browsers in general. Your code can also ask the browser it's running in. This is called feature detection: check that a name exists before you use it. It's like tapping your card on the reader to see if it beeps, instead of asking which bank the shop uses.

Ask your browser which parts it hasPop out in the code editor (opens in a new tab)HTML
<script>  const parts = {    "Custom elements": "customElements" in window,    "Declarative shadow DOM": "shadowRootMode" in HTMLTemplateElement.prototype,    "Scoped registries": "initialize" in CustomElementRegistry.prototype,    "moveBefore()": "moveBefore" in Element.prototype,    "Reference Target": "referenceTarget" in ShadowRoot.prototype,  };  for (const [part, works] of Object.entries(parts)) {    console.log(`${part}: ${works ? "yes" : "no"}`);  }</script>
ResultLoading…
  • Lines 2 to 8 make an object called parts. Each line pairs a part's name with a question.
  • Each question uses in, which asks if an object has a property with that name. The answer is true or false.
  • Line 6 asks Element.prototype. That's the object every element gets its methods from. So a method there is a method every element has.
  • Lines 9 to 11 go through the parts and print each one with yes or no.

In Chrome, all five lines say yes. In Safari 26 or later, two say no: moveBefore() and Reference Target. In Firefox 159 or later, only Reference Target says no. Feature detection is how a component uses a new part only where it exists.

Do you still need polyfills?

A polyfill is extra code that fakes a missing feature. Old tutorials load a set called webcomponentsjs on every page. You don't need it for custom elements, shadow DOM, templates, or slots. Every major browser has had them since January 2020. Scoped registries are the one exception: they reached the last browser in October 2026. A site that must work in older browsers can still load a polyfill for them.

What's new in web components since 2023?

At the start of 2023, the browsers still differed. Chrome had declarative shadow DOM and form-associated elements. Safari had neither, and Firefox had no declarative shadow DOM. Most of those gaps closed over the next few years. Here is what arrived, year by year:

  • 2023. Safari 16.4 added declarative shadow DOM, form-associated custom elements, and constructable style sheets. Chrome 111 moved declarative shadow DOM to its standard attribute, shadowrootmode.
  • 2024. Firefox 123 added declarative shadow DOM, so every browser had it. Two smaller parts reached every browser too: :state() and getHTML().
  • 2025. Safari 26 shipped scoped custom element registries, the first browser to do so. Chrome and Firefox added moveBefore().
  • 2026. Firefox 147 added CSS module scripts. Chrome 146 and Firefox 159 shipped scoped registries, so they became Baseline in October. Chrome 152 turned on Reference Target.

A few of these names are new. Here is each one in plain words:

  • Form-associated custom elements are tags that take part in a form, like an <input> does. Stage 6 is all about them.
  • Constructable style sheets are style sheets made in JavaScript. Many shadow roots can share one.
  • :state() lets CSS style a component by a state it sets, like "sold out".
  • getHTML() turns an element back into HTML, and can include its shadow root.

The rest of this section shows the two biggest arrivals running.

The browser makers fix it together

How did the gaps close? Every year, the browser makers run a project called Interop. Apple, Google, Microsoft, Mozilla, and others pick a list of focus areas together: features to fix that year. Web developers suggest them. Then every browser runs the same tests and fixes what fails.

Real-life analogyOne recipe, three kitchens

A tea shop has kitchens in three towns. Each gets the same cake recipe, but each bakes it a little differently. So the head office sends one set of taste tests to all three. Every week, each kitchen checks its cakes and fixes what's off. In the end, every cake passes in every kitchen.

In real life: The three kitchens
In JavaScript: The three browser engines: Chrome's (which Edge uses too), Firefox's, and Safari's
In real life: The recipe
In JavaScript: The standard
In real life: The shared taste tests
In JavaScript: One set of tests that every browser runs
In real life: The share of cakes that pass in every kitchen
In JavaScript: The Interop score

Web components were a focus area in Interop 2023. When the year began, 60% of its tests passed in all three browsers. By the end, 96% did. In 2024 the focus was declarative shadow DOM: it went from 54% to 100%. Scoped registries are a focus area of Interop 2026, and the Interop 2026 dashboard shows their score. That's why these parts behave the same in every browser, not just exist in every browser.

A shadow root written in HTML

In the last lesson, a shadow root needed JavaScript: attachShadow(). Declarative shadow DOM lets you write it in HTML instead. That helps when a server builds the page. The shadow root arrives with the HTML, before any script runs.

A shadow root with no JavaScriptPop out in the code editor (opens in a new tab)HTML
<tea-card>  <template shadowrootmode="open">    <p>Today's tea: <slot></slot></p>  </template>  Green tea</tea-card>
ResultLoading…
  • Line 1 opens a <tea-card>. No class is defined for it, and there's no script at all.
  • Line 2 is a <template> with shadowrootmode="open". The browser doesn't keep it as a template. It turns it into the card's shadow root.
  • Line 3 is what goes inside the shadow root: a paragraph with a slot.
  • Line 5 is the card's own text, Green tea. It shows up in the slot.

The result shows Today's tea: Green tea. It's the slot card from the last lesson, made with HTML alone.

Scoped custom element registries

Each page has one registry: the browser's list of tag names and their classes. You reach it through customElements, and each name can be in it only once. Watch what happens when two classes both want tea-label:

Two classes, one name (an error on purpose)Pop out in the code editor (opens in a new tab)JavaScript
class ShopLabel extends HTMLElement {}
class BoxLabel extends HTMLElement {}

customElements.define("tea-label", ShopLabel);
customElements.define("tea-label", BoxLabel);
  • Lines 1 and 2 make two classes.
  • Line 4 registers tea-label with ShopLabel.
  • Line 5 tries the same name again, with BoxLabel. Chrome throws a NotSupportedError: the name "has already been used with this registry".

Chrome's release notes give the real-world case. An app can use components from more than one library, and two of them can pick the same name. A scoped registry fixes it. It's a second registry that only some parts of the page use. Think of two stalls in one market that both sell a "house blend". Each makes it from its own recipe book.

The same name in a second registryPop out in the code editor (opens in a new tab)HTML
<tea-label></tea-label><div id="box"></div> <script>  class ShopLabel extends HTMLElement {    connectedCallback() { this.textContent = "Shop label"; }  }  class BoxLabel extends HTMLElement {    connectedCallback() { this.textContent = "Box label"; }  }  customElements.define("tea-label", ShopLabel);   const boxTags = new CustomElementRegistry();  boxTags.define("tea-label", BoxLabel);  const box = document.querySelector("#box");  const shadow = box.attachShadow({ mode: "open", customElementRegistry: boxTags });  shadow.innerHTML = "<tea-label></tea-label>";</script>
ResultLoading…
  • Lines 5 to 10 are the two classes again. Each one sets its own text.
  • Line 11 registers ShopLabel in the page's registry, as usual.
  • Line 13 makes a new, empty registry with new CustomElementRegistry().
  • Line 14 registers BoxLabel in it, under the same name.
  • Lines 15 and 16 find the box and give it a shadow root. The customElementRegistry option tells that shadow root to use the new registry.
  • Line 17 puts a <tea-label> inside that shadow root.

The result shows Shop label and Box label. Inside the box, the browser looks the name up in boxTags. Everywhere else, it uses customElements.

One name, two registries. In the page, tea-label is built from ShopLabel, from the customElements registry, and shows Shop label. In the box, tea-label is built from BoxLabel, from the boxTags registry, and shows Box label.pagetea-labelShopLabelregistry: customElementsshows: Shop labelboxtea-labelBoxLabelregistry: boxTagsshows: Box label
On the page, tea-label is built from ShopLabel. Inside the box's shadow root, the same name is built from BoxLabel, because that shadow root uses its own registry, boxTags.

Safari shipped scoped registries first, in Safari 26. Firefox 159 was last, in October 2026, and that made them Baseline.

What happened to HTML Imports, v0, and /deep/?

The first versions of web components were drafts. Chrome shipped them, and what developers learned from them shaped the standards. Firefox and Safari never built them. Those drafts are called v0. The versions every browser has today are called v1. The v0 drafts had three parts:

  • Custom elements v0: document.registerElement(), with createdCallback, attachedCallback, and detachedCallback.
  • Shadow DOM v0: createShadowRoot(), and <content> where today you write <slot>.
  • HTML Imports: <link rel="import">, which loaded a whole HTML file of components.

Chrome removed all three in Chrome 80, in February 2020. Ask your own browser:

Ask for three names from the v0 daysPop out in the code editor (opens in a new tab)JavaScript
console.log("registerElement" in document);
console.log("createShadowRoot" in Element.prototype);
console.log("import" in document.createElement("link"));
  • Line 1 asks if document has registerElement.
  • Line 2 asks if elements have createShadowRoot.
  • Line 3 asks if a <link> element has import, the property HTML Imports added.

All three print false, in every browser. In place of HTML Imports, components now ship as JavaScript files, loaded with <script type="module">. See why JavaScript has modules for how those work.

/deep/ and ::shadow

Shadow DOM v0 also had two CSS selectors, /deep/ and ::shadow. They let the page style anything inside any shadow root. The CSS Working Group dropped /deep/: it showed too much of a component's inside to the page. Chrome made it do nothing in Chrome 63, in 2017. ::shadow went with the rest of v0.

Today, a component chooses what the page may style. It names parts of its inside with part="", and the page styles them with ::part(). Stage 4 covers styling in full.

Old names fail without an error

Here's the trap. registerElement() throws an error, so you notice. But an old CSS selector or HTML attribute fails quietly. The browser skips what it doesn't know, and the page just looks wrong. Try each button:

Playground: an old name, or today's name
A tea card with /deep/ (old)Pop out in the code editor (opens in a new tab)HTML
<style>  tea-card /deep/ p { color: red; }</style> <tea-card></tea-card> <script>  class TeaCard extends HTMLElement {    constructor() {      super();      this.attachShadow({ mode: "open" }).innerHTML = '<p>Green tea</p>';    }  }  customElements.define("tea-card", TeaCard);  console.log(document.styleSheets[0].cssRules.length);</script>
ResultLoading…
Try it yourself
Old name: dropped without an error

Line 2 uses /deep/. The browser doesn't understand it, so it throws the whole rule away without a word. Green tea stays its normal color, and line 15 prints 0: the style sheet has no rules left.

Each button runs a fresh page in your browser. The old names don't throw errors. The browser skips them, and the page just looks wrong.

With /deep/, the browser throws the whole rule away, and line 15 prints 0. With ::part(), the rule stays, and Green tea turns red. With the old shadowroot, you see only the words Green tea. With shadowrootmode, the card is built. So "no errors" doesn't mean "up to date". Read the names too.

Old name, today's name

Read each row across: the name an old tutorial uses, what to write today, and when the old name went.

Old names and today's names
Old nameTodayWhen it went
document.registerElement()customElements.define()Custom elements v0, removed in Chrome 80.
createdCallback, attachedCallback, detachedCallbackconstructor(), connectedCallback(), disconnectedCallback()Custom elements v0, removed in Chrome 80.
createShadowRoot()attachShadow({ mode: "open" })Shadow DOM v0, removed in Chrome 80.
<content><slot>Shadow DOM v0, removed in Chrome 80.
<link rel="import"><script type="module">HTML Imports, removed in Chrome 80.
/deep/ and ::shadow::part() or CSS custom propertiesGone with shadow DOM v0.
shadowroot="open"shadowrootmode="open"Removed in Chrome 119, in 2023.
getInnerHTML()getHTML()Removed in Chrome 129, in 2024.
:--name:state(name)Replaced in Chrome 125, in 2024.
assert { type: "css" }with { type: "css" }Removed in Chrome 126, in 2024.

Which parts don't work in every browser yet?

Four parts in the support table still have limited availability. You can use them. Just plan for the browsers that don't have them.

Customized built-in elements with the is attribute

So far, every custom tag was new, like <tea-label>. A customized built-in element is different. It's a tag HTML already has, like <button>, with your class added through the is attribute.

A button with extras, through isPop out in the code editor (opens in a new tab)HTML
<button is="order-button">Order green tea</button> <script>  class OrderButton extends HTMLButtonElement {    connectedCallback() {      this.addEventListener("click", () => {        this.textContent = "Ordered!";      });    }  }  customElements.define("order-button", OrderButton, { extends: "button" });  console.log(document.querySelector("button") instanceof OrderButton);</script>
ResultLoading…
  • Line 1 is a normal <button>, with is="order-button".
  • Line 4 makes a class that extends HTMLButtonElement, not HTMLElement. So it starts with everything a button has.
  • Lines 6 to 8 change the text to Ordered! when the button is clicked.
  • Line 11 registers it. The third argument, { extends: "button" }, names the built-in tag it extends.
  • Line 12 prints true in Chrome. The button is now an OrderButton.

Click the button in the result. It changes to Ordered!. But Safari doesn't support this, and won't. WebKit, the engine that runs web pages in Safari, opposes customized built-ins. In September 2026 it said no again. In Safari, the button stays a plain button. It still works, but your class never runs, and line 12 prints false.

Real-life analogyA badge on a waiter's apron

A café gives one waiter a badge that says "tea expert". Here, the badge means an extra job: the waiter also explains each tea. In the café next door, nobody reads badges. The same waiter still takes orders there, but explains nothing.

In real life: The waiter
In JavaScript: The built-in <button>
In real life: The badge
In JavaScript: is="order-button"
In real life: The extra job
In JavaScript: Your OrderButton class
In real life: The café that reads badges
In JavaScript: Chrome and Firefox
In real life: The café next door
In JavaScript: Safari: a working button, without your class

The way that works everywhere: wrap a normal button in your own tag, like <order-button><button>…</button></order-button>. Exercise 6 asks you to build it.

Reference Target for labels inside shadow DOM

In HTML, <label for="note"> points at the element with id="note". Click the label, and the cursor goes there. But an ID can't point into a shadow root. So a label can point at your tag, but not at the input inside it.

Reference Target fixes this. The shadow root names one element inside as its reference target. Whatever points at the tag by ID is passed on to that element. It's like a front desk that passes your note to the right person.

A label that reaches the input insidePop out in the code editor (opens in a new tab)HTML
<label for="note">Order note</label><tea-note id="note"></tea-note> <script>  class TeaNote extends HTMLElement {    constructor() {      super();      const shadow = this.attachShadow({ mode: "open", referenceTarget: "box" });      shadow.innerHTML = '<input id="box">';    }  }  customElements.define("tea-note", TeaNote);</script>
ResultLoading…
  • Line 1 is a label for note. Line 2 is a <tea-note> with id="note".
  • Line 8 attaches a shadow root with referenceTarget: "box".
  • Line 9 puts an input with id="box" inside it.

Click Order note in the result. In Chrome, the cursor jumps into the input. In browsers without Reference Target, nothing happens.

Reference Target. A label with for="note" points at the tea-note element. Its shadow root sets referenceTarget to "box", so the browser forwards the label to the input with id "box" inside the shadow root.<label for="note">tea-notereferenceTarget: "box"forwards to<input id="box">Click the label: the cursor goes to the input.
The label points at <tea-note>. Its shadow root names box as its reference target, so the browser passes the label on to the input inside.

Reference Target is on by default only in Chrome, from Chrome 152. Firefox and Safari have it behind a setting, and its text is still waiting to join the HTML standard. Stage 5 shows what it means for screen readers.

CSS module scripts

A CSS module script loads a CSS file into JavaScript as a ready-made style sheet. A component can share it with its shadow root. This code needs a server that sends tea.css, so it isn't run here:

Import a CSS file as a style sheetJavaScript
import sheet from "./tea.css" with { type: "css" };
document.adoptedStyleSheets = [sheet];
  • Line 1 imports tea.css. with { type: "css" } says "this file is CSS, not JavaScript".
  • Line 2 applies the sheet to the page with adoptedStyleSheets.

It works in Chrome and Firefox, not in Safari. Older tutorials write assert where today's code says with. Chrome removed assert in Chrome 126, so that line now throws a SyntaxError.

moveBefore()

Moving an element normally takes it off the page and puts it back. That resets some things. An <iframe> inside it reloads, and focus is lost. moveBefore() moves it in one step, so nothing resets. Chrome and Firefox have it. Safari doesn't yet.

Check before you use

For these four parts, use feature detection, like the check earlier in this lesson. Then give other browsers a simpler version that still works. Now sort each piece onto its shelf, as in the picture at the top:

Every browser, some browsers, or removed?
  • customElements.define()
  • attachShadow()
  • <template shadowrootmode>
  • new CustomElementRegistry()
  • <button is="order-button">
  • referenceTarget
  • with { type: "css" }
  • moveBefore()
  • document.registerElement()
  • <link rel="import">
  • /deep/
  • shadowroot="open"
Try it yourself
0 of 12 correct

Sort each piece by where it works today.

Choose a category for every card. You can change an answer at any time; Reset clears them all.

How to tell if a web components tutorial is out of date

Tutorials don't always show a date. Even a date doesn't tell you everything. A post can be right about custom elements and out of date on declarative shadow DOM. The names in the code are a better clue.

Real-life analogyDating an old photo

You find a family photo with no date on the back. But someone in it holds a phone with a long antenna. You can't name the year, but you know the photo is old. The things in the picture tell you.

In real life: A photo with no date
In JavaScript: A tutorial with no date
In real life: A phone with a long antenna
In JavaScript: An old name, like createdCallback or /deep/
In real life: Knowing it's old without the exact year
In JavaScript: Knowing the code was written for older browsers
In real life: Today's phones
In JavaScript: Today's names: customElements.define(), <slot>, shadowrootmode

Look for these signs:

  • document.registerElement(), createShadowRoot(), <content>, or <link rel="import">: written for the v0 drafts, which Chrome removed in 2020.
  • /deep/ or ::shadow in CSS: also from v0.
  • shadowroot= or getInnerHTML(): from Chrome's first try at declarative shadow DOM.
  • assert in an import, or a state written :--name: both changed in 2024.
  • "Safari can't do this": check the support table. Safari shipped several parts before the others.

Or let this checker read the code for you. Pick each sample, or paste code from a tutorial you found:

Playground: date a tutorial by its names
Removed names in this code
  • Line 2: createdCallbackToday: constructor(). Custom elements v0, removed in Chrome 80, in 2020.
  • Line 3: createShadowRoot()Today: attachShadow({ mode: "open" }). Shadow DOM v0, removed in Chrome 80, in 2020.
  • Line 4: <content>Today: <slot>. Shadow DOM v0, removed in Chrome 80, in 2020.
  • Line 6: document.registerElement()Today: customElements.define(). Custom elements v0, removed in Chrome 80, in 2020.
Try it yourself
4 removed names found

This code was written for browsers before these names went away. Use today's names instead.

The checker looks for the removed names from this lesson's table, such as registerElement, /deep/, and shadowroot=. It only reads the text: nothing you paste is run.

The first sample has four old names. "Today's tea card" has none: it uses with, attachShadow(), and customElements.define(). The checker knows the names in this lesson's table. A clean result is a good sign, but still glance at the date.

Common mix-ups

  • "Safari is behind on web components." No. Safari shipped declarative shadow DOM almost a year before Firefox, and it shipped scoped registries first. Its real gaps are is="", CSS module scripts, moveBefore(), and Reference Target.
  • "You need the webcomponentsjs polyfills." No. Custom elements, shadow DOM, templates, and slots have worked in every major browser since January 2020.
  • "Web components can't be built on a server." No. Declarative shadow DOM writes a shadow root in HTML, and it has been widely available since August 2026.
  • "is="" works everywhere." No. Safari doesn't support it, and WebKit has said it won't. Wrap a normal element in your own tag instead.
  • "/deep/ lets the page style inside any shadow root." No. Browsers dropped it. A component names its parts with part="", and the page styles them with ::part().
  • "Code that runs without errors is up to date." No. Old HTML attributes and CSS selectors fail without an error. Check the names.

Practice exercises

Answer first, then use the hints. The live results let you check yourself.

Exercise 1 · Warm-upAsk for an old name

What does this line print in your browser?

Starter codePop out in the code editor (opens in a new tab)JavaScript
console.log("createShadowRoot" in Element.prototype);

Answer, then press Check. Spacing and letter case don’t matter.

    Exercise 2 · Warm-upWhich one isn't Baseline?

    Which of these four parts isn't Baseline?

    1. Declarative shadow DOM
    2. Form-associated custom elements
    3. Scoped custom element registries
    4. Customized built-in elements, is=""

    Answer, then press Check. Spacing and letter case don’t matter.

      Exercise 3 · PracticeFix an old card

      This card from an older tutorial shows only Green tea. Fix it. What does the card show then?

      <tea-card>  <template shadowroot="open">    <p>Today's tea: <slot></slot></p>  </template>  Green tea</tea-card>
      ResultLoading…

      Answer, then press Check. Spacing and letter case don’t matter.

        Exercise 4 · PracticeRewrite a v0 label

        This label throws an error in every browser. Rewrite it with today's names. What does your page show?

        <tea-label></tea-label> <script>  const proto = Object.create(HTMLElement.prototype);  proto.attachedCallback = function () {    this.textContent = "Black tea: brew for 4 minutes";  };  document.registerElement("tea-label", { prototype: proto });</script>
        ResultLoading…

        Answer, then press Check. Spacing and letter case don’t matter.

          Exercise 5 · ChallengeDate a snippet

          This snippet saves a card as HTML, with its shadow root. Which old name dates it, and what do you write today instead?

          Starter codeJavaScript
          const card = document.querySelector("tea-card");
          const html = card.getInnerHTML({ includeShadowRoots: true });
          console.log(html);

          Answer, then press Check. Spacing and letter case don’t matter.

            Exercise 6 · ChallengeAn order button for every browser

            This button only gets its extra job in Chrome and Firefox. Rewrite it without is, so it works in Safari too. Click it. What does the button say?

            <button is="order-button">Order green tea</button> <script>  class OrderButton extends HTMLButtonElement {    connectedCallback() {      this.addEventListener("click", () => {        this.textContent = "Ordered!";      });    }  }  customElements.define("order-button", OrderButton, { extends: "button" });  console.log(document.querySelector("button") instanceof OrderButton);</script>
            ResultLoading…

            Answer, then press Check. Spacing and letter case don’t matter.

              Check your understanding

              For each question, ask: does it work in every browser, in some, or in none any more?

              The web components today quiz · 7 questionsScore: first tries count
              1. Question 1 of 7What does "Baseline widely available" mean?

                Choose an answer to see the explanation.

              2. Question 2 of 7What does this card from an older tutorial show in Chrome today?

                Read the code, then predictPop out in the code editor (opens in a new tab)HTML
                <tea-card>
                  <template shadowroot="open">
                    <p>Today's tea: <slot></slot></p>
                  </template>
                  Green tea
                </tea-card>

                Choose an answer to see the explanation.

              3. Question 3 of 7Which part works in Chrome and Firefox, but WebKit has said it won't build for Safari?

                Choose an answer to see the explanation.

              4. Question 4 of 7An old tutorial loads a component with <link rel="import">. What do you use today?

                Choose an answer to see the explanation.

              5. Question 5 of 7In the scoped registry example, what does the <tea-label> inside the box show?

                Read the code, then predictPop out in the code editor (opens in a new tab)HTML
                <tea-label></tea-label>
                <div id="box"></div>
                
                <script>
                  class ShopLabel extends HTMLElement {
                    connectedCallback() { this.textContent = "Shop label"; }
                  }
                  class BoxLabel extends HTMLElement {
                    connectedCallback() { this.textContent = "Box label"; }
                  }
                  customElements.define("tea-label", ShopLabel);
                
                  const boxTags = new CustomElementRegistry();
                  boxTags.define("tea-label", BoxLabel);
                  const box = document.querySelector("#box");
                  const shadow = box.attachShadow({ mode: "open", customElementRegistry: boxTags });
                  shadow.innerHTML = "<tea-label></tea-label>";
                </script>

                Choose an answer to see the explanation.

              6. Question 6 of 7Which browser shipped scoped custom element registries first?

                Choose an answer to see the explanation.

              7. Question 7 of 7A tutorial's code runs without any error. Is it up to date?

                Choose an answer to see the explanation.

              Key takeaways

              • Custom elements, shadow DOM, templates, and slots work in every major browser, and have since January 2020.
              • Baseline says how safe a part is: newly available when every core browser has it, widely available 30 months later.
              • From 2023 to 2026, declarative shadow DOM, form-associated elements, :state(), and scoped registries reached every browser.
              • The v0 names and HTML Imports were only ever in Chrome, which removed them in 2020. /deep/ and ::shadow are gone too.
              • is="", Reference Target, CSS module scripts, and moveBefore() work in only some browsers. Check before you use them.
              • Old JavaScript names throw errors, but old HTML and CSS names fail quietly. Date a tutorial by its names.

              Remember the one-liner.
              The core of web components works in every browser. Old tutorials use names that are gone, and a few new parts work in only some browsers.

              Sources

              The facts on this page come from these standards, data sets, and release notes:

              Coming next: When to use web components, and when not. When a web component is the right tool, and when something else fits better.

              CompleteFrontend Clear concepts. Working examples.