I have recently discovered the HTML template
element, and would appreciate some clarification.
As far as I can tell, the three distinguishing features are:
template
is not rendered on screentemplate
does not make its way to the DOM- there is an additional
content
property which acts as a virtual element between thetemplate
and its contents
Aside from these, a <template>
might have been a div
, hidden from the screen and the DOM. In this regard, the JavaScript used to take advantage of the template
is the same as if trying to fake one using a div
.
Is this correct? I ask because it would be relatively easy to fake one for nonsupporting browsers.