【问题标题】:data-attributes is there a limit of length and how many?数据属性有长度限制吗?有多少?
【发布时间】:2019-10-04 18:02:48
【问题描述】:

html的数据属性有限制吗?一个标签上可以有很多数据属性吗?

例如。 data-a="" data-b="" data-c="" ... data-z=""

每个数据属性的值是否有限制?

【问题讨论】:

标签: html custom-data-attribute


【解决方案1】:

每个 HTML 元素都可以指定任意数量的自定义数据属性,并具有任意值。

来源:w3.org: 3.2.5.9 Embedding custom non-visible data with the data-* attributes

长度的限制已经在上面 Mary Melody 链接的上一个问题中讨论过:Is there a limit to the length of HTML attributes?

【讨论】:

    【解决方案2】:

    我很担心。在 JavaScript 中定义数据属性时,它们没有最大长度,只要记住始终使用小写 [-variable]

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      • 1970-01-01
      • 1970-01-01
      • 2014-04-28
      相关资源
      最近更新 更多