The is
global attribute allows you to specify that a standard HTML element should behave like a defined custom built-in element (see Using custom elements for more details).
This attribute can only be used if the specified custom element name has been successfully defined in the current document, and extends the element type it is being applied to.
The following code is taken from our word-count-web-component example (see it live also).
// Create a class for the element class WordCount extends HTMLParagraphElement { constructor() { // Always call super first in constructor super(); // Constructor contents ommitted for brevity ... } } // Define the new element customElements.define('word-count', WordCount, { extends: 'p' });
<p is="word-count"></p>
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'is' in that specification. | Living Standard |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 67 | No | 63
|
No | 55 | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 67 | 67 | No | 63
|
55 | No | No |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is