← All Exercises

Custom Elements API

advancedhtml~25min

Background

Custom elements enable creating reusable HTML components with native browser support.

Problem

Define a custom element with lifecycle callbacks using customElements.define.

Input

Custom element definition

Output

Reusable custom component

Sample tests

Sample 1

Input: custom element <my-card>
Expected: component rendered

Your solution

Learning objective

Learn Web Components and custom element lifecycle