What is HTML “is” attribute?

后端 未结 5 573
南方客
南方客 2020-12-05 14:11

I have seen it a lot here and there, yet I could find any description or documentation about it!

Example:



        
5条回答
  •  时光取名叫无心
    2020-12-05 14:29

    You use the is attribute to markup a customized built-in element, a custom element that extends a built-in element.

    There are two types of custom elements:

    Autonomous custom elements are standalone — they don’t inherit from standard HTML elements. You use these on a page by literally writing them out as an HTML element. For example , or document.createElement("popup-info").

    Customized built-in elements inherit from basic HTML elements. To create one of these, you have to specify which element they extend (as implied in the examples above), and they are used by writing out the basic element but specifying the name of the custom element in the is attribute (or property). For example

    , or document.createElement("p", { is: "word-count" }).

    https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements

提交回复
热议问题