HTML <template> tag
HTML <template> tag is used to hold the client-side content that will not render at the time of page load, but it can be instantiated during runtime using JavaScript.
The content of the template will not be displayed until it is not activated using JavaScript. The browser processes the content of the <template> element while loading the page to ensure that the content is valid, the contents are not rendered, however.
It can also be useful when you want to use same content multiple times in your HTML document without any change.
The <template> tag can be placed anywhere inside of <head>, <body>, <frameset>, or <table> elements.
The <template> tag is newly added element in HTML5.
Syntax
Following are some specifications about the HTML <template> tag
Display | None |
Start tag/End tag | Start and End tag |
Usage | Formatting |
Example
Output:
Attribute:
Tag-specific attributes:
The <template> tag does not contain any specific attribute.
Global attribute:
The <template> tag supports the Global attributes in HTML.
Supporting Browsers
Element | Chrome | IE | Firefox | Opera | Safari |
<template> | Yes | No | Yes | Yes | Yes |