The <slot> element is a placeholder inside a Web Component that you fill with your own markup when the component is used. It lets you keep a private shadow tree while composing light-DOM content into it.
Use the name attribute for named slots. Host children with a matching slot attribute are projected there. An unnamed <slot> is the default slot. Markup inside the slot is fallback content.
Baseline · Widely available.
Stable across browsers since about January 2020. Pair with attachShadow() or declarative shadow DOM via <template>.
Shadow trees only.
Slots project content when they live in a shadow root. Outside Shadow DOM they behave like ordinary elements.
Syntax
HTML Syntax
syntax.html
<slotname="title">fallback</slot>
Both start and end tags are required. Fallback content sits between the tags.
Reference
Attributes
Besides global attributes, <slot> defines:
Attribute
Description
Try it
name
Named slot identifier. Host children with slot="…" match this name. Omit for the default slot
Browser shows the fallback until a matching child appears.
Assign content later to replace the fallback automatically.
Watch out
Edge Cases & Pitfalls
shadow
Slots outside Shadow DOM
Without a shadow root, <slot> does not project light-DOM children.
names
Duplicate slot names
Keep names unique per shadow root. Duplicates send nodes to the first matching slot.
attr
Confusing name and slot
name goes on <slot>. The host child uses the slot attribute to choose a destination.
depth
Only top-level host children
With named assignment, only direct children of the host are distributed (not nested descendants).
legacy
Obsolete <shadow>
Do not use the old <shadow> tag. Use attachShadow + <slot>.
events
Listening for updates
Use the slotchange event when assigned nodes change and your UI must react.
Compatibility
Browser Support
The <slot> element is core HTML for Shadow DOM composition. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<slot>
Widely available since about January 2020. Chrome, Firefox, Safari, Edge, and Opera support Web Component slots.
95%Global support (approx.)
Google Chrome53+
Full support
Mozilla Firefox63+
Full support
Apple Safari10+
Full support
Microsoft Edge79+
Full support
Opera40+
Full support
Samsung Internet6+
Full support
Internet Explorer—
Not supported
<slot>Widely supported
Bottom line: Safe for modern Web Components. Always place slots inside a shadow root.
Remember
Key Takeaways
Role: placeholders that project light-DOM into a shadow tree.
name: named slots; omit for the default slot.
Fallback: children of the slot show when unassigned.
Practice: pair with attachShadow or <template>.
One line: put <slot> in the shadow tree, and match host children with slot="…".
UA style
Default CSS Settings
Slots are typically transparent layout-wise; approximate idea:
default.css
slot {
display: contents; /* common author pattern; UA may vary */
}
Style wrappers around the slot in the shadow tree rather than relying on the slot box itself.
Frequently Asked Questions
A slot is a placeholder inside a Web Component’s shadow tree. Light-DOM children of the host are projected into matching slots so authors can customize the component’s content.
name identifies a named slot. Host children with a matching slot attribute are rendered there. An unnamed slot is the default slot for children without a slot attribute.
Markup placed between the slot’s start and end tags is shown when nothing is assigned to that slot. Once content is assigned, the fallback is not displayed.
Slots only act as insertion points when they live in a shadow root (for example from attachShadow or a template with shadowrootmode). Outside shadow trees they are ordinary elements.
Slot names should be unique per shadow root. If two slots share a name, assigned nodes go to the first matching slot.
slotchange fires on a slot when the nodes assigned to it change. Use it to react when projected content is added or removed.