HTML <slot> Tag
Example
The template element holds HTML code without displaying it:
<template>
<div>Name:
<slot
name="username"></slot>
</div>
<div>Birthday:
<slot name="birthday"></slot>
</div>
</template>
Try it Yourself »
Definition and Usage
The <slot> tag is a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.
Use the <template> tag when you have HTML code you want to use over and over again, but not until you ask for it.
Browser Support
Element | |||||
---|---|---|---|---|---|
<slot> | 53.0 | 79.0 | 63.0 | 10.0 | 40.0 |
Attributes
Attribute | Value | Description |
---|---|---|
name | Specifies the name of the slot |
Global Attributes
The <slot> tag supports the Global Attributes in HTML.