MDN self-hosted library · e01.org

CustomElementRegistry: define() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
class MyAutonomousElement extends HTMLElement {
  constructor() {
    super();
  }
}
js
customElements.define("my-autonomous-element", MyAutonomousElement);
html
<my-autonomous-element>Element contents</my-autonomous-element>
js
class MyCustomizedBuiltInElement extends HTMLParagraphElement {
  constructor() {
    super();
  }
}
js
customElements.define(
  "my-customized-built-in-element",
  MyCustomizedBuiltInElement,
  {
    extends: "p",
  },
);
html
<p is="my-customized-built-in-element"></p>