What is the “generated” attribute seen in some HTML tag used for?

前端 未结 2 1517
走了就别回头了
走了就别回头了 2021-01-11 18:13

I saw it used in a HTML label tag but I have a feeling that it can be used with most HTML tags. I can kinda guess what it means. But I am more curious about what\'s the bene

2条回答
  •  执念已碎
    2021-01-11 18:27

    This is a custom data or user-defined attribute. In your case it has been added to denote an element that was generated on the page after it loaded, probably by JavaScript.

    It's common to see other such attributes in heavy UI/UX web applications. They typically serve as hooks between technologies - CSS, JavaScript, HTML, etc.

    Note that such attributes do not validate. If you are using HTML5, you can prefix them with data- to get around this issue (i.e. data-generated="true"). Read more about custom data attributes in HTML5.

提交回复
热议问题