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.

Warning: document.registerElement() is deprecated in favor of customElements.define().

The document.registerElement() method registers a new custom element in the browser and returns a constructor for the new element.

Note: This is an experimental technology. The browser you use it in must support Web Components. See Enabling Web Components in Firefox.


registerElement(tagName, options)



The name of the custom element. The name must contain a dash (-), for example my-tag.

options Optional

An object with properties prototype to base the custom element on, and extends, an existing tag to extend. Both of these are optional.

Return value

None (undefined).


Here is a very simple example:

const MyTag = document.registerElement("my-tag");

Now the new tag is registered in the browser. The MyTag variable holds a constructor that you can use to create a my-tag element in the document as follows:

document.body.appendChild(new MyTag());

This inserts an empty my-tag element that will be visible if you use the browser's developer tools. It will not be visible if you use the browser's view source capability. And it won't be visible in the browser unless you add some content to the tag. Here is one way to add content to the new tag:

const myTagElement = document.querySelector("my-tag");
myTagElement.textContent = "I am a my-tag element.";

Browser compatibility

BCD tables only load in the browser

See also