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.
This interface inherits the properties of HTMLElement.
content Read only
A read-only DocumentFragment which contains the DOM subtree representing the <template> element's template contents.
shadowRootModeA string that reflects the value of the shadowrootmode attribute of the associated <template> element.
shadowRootDelegatesFocusA boolean that reflects the value of the shadowrootdelegatesfocus attribute of the associated <template> element.
shadowRootClonableA boolean that reflects the value of the shadowrootclonable attribute of the associated <template> element.
shadowRootSerializableA boolean that reflects the value of the shadowrootserializable attribute of the associated <template> element.
This interface inherits the methods of HTMLElement.
| Specification |
|---|
| HTML> # htmltemplateelement> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HTMLTemplateElement |
26 | 13 | 22 | 15 | 8 | 26 | 22 | 14 | 8 | 1.5 | 4.4 | 8 |
content |
26 | 13 | 22 | 15 | 8 | 26 | 22 | 14 | 8 | 1.5 | 4.4 | 8 |
shadowRootClonable |
124 | 124 | 125 | 110 | 18 | 124 | 125 | 82 | 18 | 27.0 | 124 | 18 |
shadowRootCustomElementRegistry |
No | No | No | No | 26 | No | No | No | 26 | No | No | 26 |
shadowRootDelegatesFocus |
123 | 123 | 123 | 109 | 18 | 123 | 123 | 82 | 18 | 27.0 | 123 | 18 |
shadowRootMode |
111 | 111 | 123 | 97 | 16.4 | 111 | 123 | 75 | 16.4 | 22.0 | 111 | 16.4 |
shadowRootSerializable |
125 | 125 | 128 | 111 | 18 | 125 | 128 | 83 | 18 | 27.0 | 125 | 18 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement