The HTMLTemplateElement.content property returns a <template> element's template contents (a DocumentFragment).


var documentFragment = templateElement.content


var templateElement = document.querySelector("#foo");
var documentFragment = templateElement.content.cloneNode(true);


Specification Status Comment
HTML Living Standard
The definition of 'HTMLTemplateElement interface' in that specification.
Living Standard  
The definition of 'HTMLTemplateElement interface' in that specification.
Recommendation Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 26Edge Full support 13Firefox Full support 22IE No support NoOpera Full support 15Safari Full support 8WebView Android Full support YesChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 22Opera Android ? Safari iOS Full support 8Samsung Internet Android Full support Yes


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: fscholz, walterebert, sideshowbarker
Last updated by: fscholz,