W3C validation error with data-href

后端 未结 4 1075
时光说笑
时光说笑 2021-01-17 00:46

I am getting one validation error due to my use of data-href=\"\" in the context of making a whole DIV clickable. The JS and HTML is below. What could I do to make this W3C

4条回答
  •  [愿得一人]
    2021-01-17 01:13

    Since data-* is part of the HTML5specification, you need to use the html5-doctype:

    
    

    Any other doctype will parse your site according to HTML4 or XMHTML-Rules, where the data-* Attribute is invalid.

    edit:

    You should always start your html with the proper doctype. Since triggers standards-mode in all browser, this is "the only right way" except you really want XHTML for example (although I can't see a reason why you should).

    edit2:

    You might want to consider using an a anchor-tag instead, since it already has an href and is considered to be clickable?

提交回复
热议问题