HTMLTemplateElement
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since November 2015.
* Some parts of this feature may have varying levels of support.
The HTMLTemplateElement interface enables access to the contents of an HTML <template> element.
Note:
An HTML parser can create either an HTMLTemplateElement or a ShadowRoot when it parses a <template> element, depending on the <template> attributes.
If an HTMLTemplateElement is created the "shadow" attributes are reflected from the template.
However these are not useful, because an HTMLTemplateElement is not a shadow root and cannot subsequently be changed to a shadow root.
Instance properties
This interface inherits the properties of HTMLElement.
contentRead only-
A read-only
DocumentFragmentwhich contains the DOM subtree representing the<template>element's template contents. shadowRootMode-
A string that reflects the value of the
shadowrootmodeattribute of the associated<template>element. shadowRootDelegatesFocus-
A boolean that reflects the value of the
shadowrootdelegatesfocusattribute of the associated<template>element. shadowRootClonable-
A boolean that reflects the value of the
shadowrootclonableattribute of the associated<template>element. shadowRootCustomElementRegistry-
A string that reflects the value of the
shadowrootcustomelementregistryattribute of the associated<template>element, indicating that the declarative shadow root will use a scopedCustomElementRegistry. shadowRootSerializable-
A boolean that reflects the value of the
shadowrootserializableattribute of the associated<template>element.
Instance methods
This interface inherits the methods of HTMLElement.
Specifications
| Specification |
|---|
| HTML # htmltemplateelement |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
HTMLTemplateElement
|
|
|
|
|
|
|
|
|
|
|
|
|
content
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootClonable
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootCustomElementRegistry
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootDelegatesFocus
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootMode
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootReferenceTarget
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootSerializable
|
|
|
|
|
|
|
|
|
|
|
|
|
shadowRootSlotAssignment
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- In development. Supported in a pre-release version.
- In development. Supported in a pre-release version.
- No support
- No support
- Experimental. Expect behavior to change in the future.
- Non-standard. Check cross-browser support before using.
- See implementation notes.
- User must explicitly enable this feature.