<template>Baseline · Widely available
The <template> HTML element holds HTML fragments which you can clone and insert into the document using JavaScript.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Nov 12, 2015. Widely available since May 12, 2018.
Browser support
DesktopChrome
1–25Not supported
26+Supportedsince Mar 26, 2013
Current: 155Edge
12–12Not supported
13+Supportedsince Nov 12, 2015
Current: 154Firefox
1–21Not supported
22+Supportedsince Jun 25, 2013
Current: 157Safari
1–7Not supported
8+Supportedsince Oct 16, 2014
Current: 27MobileChrome Android
18–25Not supported
26+Supportedsince Apr 3, 2013
Current: 155Firefox Android
4–21Not supported
22+Supportedsince Jun 25, 2013
Current: 157Safari iOS
1–7Not supported
8+Supportedsince Sep 17, 2014
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
HTML
<template id="row">
<tr><td class="name"></td><td class="email"></td></tr>
</template>
<script>
const tpl = document.getElementById("row");
const row = tpl.content.cloneNode(true);
row.querySelector(".name").textContent = "Ada";
document.querySelector("tbody").append(row);
</script>Feature detection
JS · check before using
const el = document.createElement("template");
if (!(el instanceof HTMLUnknownElement)) {
// <template> is supported
}Documentation (MDN)
Specification
Usage share
Sub-features
Support for each part of the feature (3). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| HTMLTemplateElement | 26 | 13 | 22 | 8 | 26 | 22 | 8 |
| HTMLTemplateElement.content | 26 | 13 | 22 | 8 | 26 | 22 | 8 |
| template | 26 | 13 | 22 | 8 | 26 | 22 | 8 |