Lesson 01 — Custom Elements
Your first custom element
Custom elements are the browser's native component model. You define a class, register a tag name, and the platform handles the rest — no compiler, no runtime, no virtual DOM.
The idea
Every custom element extends HTMLElement (or a built-in element class). You register it with customElements.define, and the browser instantiates your class whenever it sees your tag in the DOM. The connectedCallback lifecycle hook runs when your element is inserted — that's where you render.
Your assignment
- Define a class called
GreetingCardthat extendsHTMLElement - In
connectedCallback, setinnerHTMLto greet the user — use thenameattribute if present, orfriendas a fallback - Register the element as
greeting-cardwithcustomElements.define
Press ‘Run checks’ to test your element against the assignment.
Nice — all checks passed. 🌱
Next lesson →