Is it a bad practice to add extra attributes to HTML elements?

后端 未结 6 604
日久生厌
日久生厌 2021-01-04 01:30

Sometimes I add an attribute to some of my controls. Like:

Chris Sharma

I know it

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-04 01:59

    It's invalid XHTML which is a bad thing - mainly because you can't show off with valid ;) Every mainstream browser and search engine will ignore extra attributes happily though. You could add an extra namespace though to make your XHTML valid again.

    
      
      Chris Sharma
      
    
    

    That's perfectly valid XHTML. However, W3C Validator will still refuse to validate it (I think). It's a shortcoming of their XML parser. For such non namespace aware parsers, my:isClimber will still be treated as would be isClimber. But you can now rest easy as you know that it is valid XML and finally that's what counts, isn't it ;)

提交回复
热议问题