template HTML

HTML <template> Tag

To hold the client-side content which is not displayed when the page loads the HTML <template> tag is used. Using Javascript it can be instantiated during runtime and thus the content can be displayed when activated using JavaScript. While using the same content multiple times in an HTML document without any modification, the HTML <template> tag is useful. It can be placed within the <head>, <body>, <frameset>, or <table> elements. It was introduced in HTML5.

Syntax:

<template>.........</template>

Example:

<!DOCTYPE html>
<html>
<body>
<h3>Example</h3>
<p>Content is hidden.</p>
<template>
<h2>Sky</h2>
<img src="img.jpg" width="300" height="200">
</template>
</body>
</html>

Explanation:

In the above example, we have used the HTML <template> tag to hide the client-side content on page loading.

Global Attributes:

The HTML Global attributes are supported by the HTML <template> tag.

Supporting Browser:

Chrome, IE, Firefox, Opera, and Safari.

Please follow and like us:
Content Protection by DMCA.com