Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
The name property of the HTMLSlotElement interface returns or sets the slot name. A slot is a placeholder inside a web component that users can fill with their own markup.
A string.
The following snippet is taken from our slotchange example (See it live).
Here we grab references to all the slots, then add a slotchange event listener to the 2nd slot in the template — which is the one that keeps having its contents changed in the example.
Every time the element inserted in the slot changes, we log a report to the console saying which slot has changed, and what the new node inside the slot is.
| HTML # dom-slot-name-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 7, 2023 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.