Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE HTML> <html> <head> <title>Title of the Document</title> </head> <body> <site-card> <div slot="sitename"> <div>W3Docs</div> </div> </site-card> <script> customElements.define('site-card', class extends HTMLElement { connectedCallback() { this.attachShadow({mode: 'open'}); this.shadowRoot.innerHTML = ` <style> ::slotted(div) { border: 2px solid blue; } </style> Sitename: <slot name="sitename"></slot> `; } }); </script> </body> </html>