Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <script> class ShadowElement extends HTMLElement { constructor() { super(); let shadow = this.attachShadow({ mode: 'open' }); shadow.innerHTML = ` <style> p { color: blue; } </style> <p>Shadow DOM content</p> `; } } customElements.define('shadow-element', ShadowElement); </script> <shadow-element></shadow-element> </div>