Site icon DW Faisalabad

HTML <template> Tag

Example

The template element holds HTML code without displaying it:

<template>
<h2>Flower</h2>
<img src=”img_white_flower.jpg”>
</template>

Try it Yourself »


Definition and Usage

The <template> tag holds its content hidden from the client.

Content inside a <template> tag will not be rendered.

The content can be visible and rendered later by using JavaScript.

Use the <template> tag when you have HTML code you want to use over and over again, but not until you ask for it. To do this without the <template> tag, you have to create the HTML code with JavaScript to prevent the browser from rendering the code.


Browser Support

Element
<template> 26.0 13.0 22.0 9 15.0

Differences Between HTML 4.01 and HTML5

The <template> tag is new in HTML5.


Global Attributes

The <template> tag supports the Global Attributes in HTML.

Exit mobile version