Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <show-welcome name="W3Docs"></show-welcome> </body> <script> customElements.define('show-welcome', class extends HTMLElement { connectedCallback() { const shadow = this.attachShadow({mode: 'open'}); shadow.innerHTML = `<h1> Welcome to ${this.getAttribute('name')} </h1>`; } }); </script> </body> </html>