Scripts & Templates
HTML <slot> element
Defines a distribution point inside a shadow tree. Named slots receive matching light-DOM children; unmatched slots may show fallback content. Slot assignment distributes light-DOM children into a shadow tree. A named slot receives matching slot attributes; an unnamed slot receives eligible default content. Fallback children appear when no nodes are assigned. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<slot name="title">Fallback</slot>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
Return Value
HTMLSlotElement
Content model: Transparent fallback content.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <div> <template shadowrootmode="open"> <h2> <slot name="title">Untitled</slot> </h2> </template> <span slot="title">Reading list</span> </div> </body></html>