Template Element
The <template> element stores HTML that is not rendered immediately. Its contents can be cloned and inserted into the document using JavaScript. Templates are useful for reusable client-side fragments and Web Components.
HTML Template
<template id="userCardTemplate">\n <article class="user-card">\n <h2 class="name"></h2>\n </article>\n</template>💡 The template's content remains inert until JavaScript clones and inserts it.
Key Takeaways
- Template content is inert until instantiated.
- Templates are useful for reusable DOM fragments.
Knowledge Check
Is template content immediately rendered as normal page content?