Course contentsShow
← Web Development
Lesson 2454 of 2,98244. Web ComponentsFree lesson

Autonomous vs Customized Built-in Elements

Understanding the difference between standalone custom elements and enhanced versions of existing HTML elements.

Autonomous vs Customized Built-in Elements

You'll learn: The two fundamental types of custom elements and when to use each one.

When building Web Components, you have two architectural choices: create a completely new element from scratch or enhance an existing HTML element with custom behavior.

Autonomous Custom Elements

Autonomous elements stand alone—they're brand-new HTML tags that don't inherit from any existing element (except the base HTMLElement). You define them like this:

class MyWidget extends HTMLElement {
  connectedCallback() {
    this.innerHTML = '<p>I am a completely new element!</p>';
  }
}
customElements.define('my-widget', MyWidget);

Use them in HTML just like any tag:

<my-widget></my-widget>

These are perfect when you're creating something entirely new—a carousel, a custom chart, or a unique UI component that doesn't map to existing HTML semantics.

Customized Built-in Elements

Customized built-in elements extend existing HTML elements, inheriting their built-in accessibility, behavior, and semantics. You extend specific element classes:

class FancyButton extends HTMLButtonElement {
  connectedCallback() {
    this.classList.add('fancy');
  }
}
customElements.define('fancy-button', FancyButton, { extends: 'button' });

Use them with the is attribute:

<button is="fancy-button">Click me</button>

This approach preserves the button's native keyboard support, form integration, and ARIA roles—everything browsers expect from a <button>.

The Choice

Think of autonomous elements as building a house from scratch, while customized built-ins are renovating an existing structure. Choose customized built-ins when you want to enhance native elements while keeping their core functionality. Choose autonomous when you need complete freedom.

Key Takeaway: Autonomous custom elements create entirely new tags extending HTMLElement, while customized built-in elements enhance existing HTML elements by extending their specific classes (like HTMLButtonElement)—preserving native behavior and semantics.