template element
An HTML element whose contents are parsed but not rendered or run, kept as a reusable blueprint that scripts copy into the page.
In more detail
The content property holds an inert DocumentFragment: images inside do not download and scripts do not run until a clone is inserted. You fill each copy with data and append it.
Related terms
- DocumentFragment — A lightweight container for DOM nodes that is not part of the page, used to build many nodes and insert them all in one step.
- cloneNode() — The DOM method that copies a node; with the argument true it copies the whole subtree as well.
- inert content — Markup the browser has parsed but deliberately keeps dormant: nothing inside is displayed, fetched or executed.
Taught in
- DOM Manipulation: DocumentFragment And HTML Templates — Frontend Architecture & Web Platform