HTML Template Tag

In HTML, the <template> tag is used for holding the client-side content on the web page.

  • One thing to note is that content inside the <template> tag will not be rendered at the time of Page Loading.

  • To render the content and make it visible at runtime JavaScript is used for this purpose.

  • While the parser does process the contents of the <template> tag while loading the page, it does so only to ensure that those contents are valid.

  • A template is just like a content fragment that is being stored for subsequent use in the document.

HTML <template> Tag Syntax and Usage

The <template> tag requires the start(opening) tag and end(closing) tag.

Following is the syntax for using the template tag in your HTML code:

<template>
..content here
</template>

HTML <template> Tag Basic Example

Below we have a basic example showing how we use the HTML template tag.

Note: We have to use javascript to see the content inside the <template> tag.

HTML <template> Tag Attributes

This tag does not have specific attributes; though it supports global and event attributes.

Browser Support for HTML <template> Tag

Following browsers support this attribute:

  • Google Chrome 6.0+

  • Firefox 4+

  • Opera 11.1+

  • Safari 5.0+