Declarative shadow DOM
Newly available since 2024-02-20
The shadowrootmode
attribute on <template>
creates a shadow root without the use of JavaScript. It is a declarative alternative to the attachShadow()
method.
To learn more, see
<template>: The Content Template element at MDN.
Compatibility (view on caniuse.com)
- Chrome 111 Released on 2023-03-07
- Chrome Android 111 Released on 2023-03-07
- Edge 111 Released on 2023-03-13
- Firefox 123 Released on 2024-02-20
- Firefox for Android 123 Released on 2024-02-20
- Safari 16.4 Released on 2023-03-27
- Safari on iOS 16.4 Released on 2023-03-27
Specifications
- HTML Standard (#attr-template-shadowrootmode), from HTML Workstream (WHATWG).