Skip to the page
html reference · other

HTML <template> tag

closing tag
required
void element
no
lives inside
<head> or <body>
typically holds
markup meant to be cloned by JavaScript later

Where it goes

Anywhere, since it is invisible. Usually near the top of <body>, out of the way.

Example

<template id="row-template">
  <li class="row"></li>
</template>

Open this example in the editor →

Common mistakes

  • Expecting it to show up on its own. It never will without JavaScript copying it in.
  • Using it as a way to hide content instead of CSS display: none. Hidden content still loads and runs. Template content does neither until copied.

Related

Updated 24 October 2026. Practice it in the html route, or read more on MDN.