Template & Slot

<template> holds inert HTML fragments. Inside, <slot> marks where dynamic content plugs in — the declarative core of Web Components.

Template Markup (inert)

<template id="card-tpl">
  <article class="tpl-card">
    <header>
      <slot name="title">Default title</slot>
    </header>
    <p><slot></slot></p>
    <footer><slot name="meta">—</slot></footer>
  </article>
</template>

Rendered result (simulated)

Custom Element

Reusable UI component with its own shadow DOM and scoped styles.

Web Components · 2024
SSR Fallback

Server-rendered initial HTML hydrated by client-side JS later.

Progressive · 180ms TTI

Three things to know

Static HTML can show only the structure — activating <template> and distributing children into slots requires JavaScript. This example visualizes what the DOM would look like after activation.