![]() |
Browsers SupportDefinition and UsageThe <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. Attributes
Global AttributesThe <slot> tag supports the Global Attributes in HTML. |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<h1>The template Element</h1>
<p>Click the button below to display the hidden content from the template element.</p>
<button onclick="showContent()">Show hidden content</button>
<template>
<h2>Flower</h2>
<img src="img_white_flower.jpg" width="214" height="204">
</template>
<script>
function showContent() {
let temp = document.getElementsByTagName("template")[0];
let clon = temp.content.cloneNode(true);
document.body.appendChild(clon);
}
</script>
</body>
</html>
html browsers support |
How to add The template element holds HTML code without displaying it | HTML Browser Support |
Read Full: | HTML Browser Support |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Browser Support |
Uploaded by: | Admin |
Views: | 18 |
Reffered: https://www.w3schools.com/tags/tag_slot.asp