HTML5 Compliant - Trailing Space in Class Attribute

后端 未结 4 2096
心在旅途
心在旅途 2021-01-12 22:20

I know that technically HTML5 is a \'living spec\' but I\'m wondering if it\'s compliant to have trailing spaces inside of a class name. I didn\'t see any reference to this

4条回答
  •  逝去的感伤
    2021-01-12 22:29

    As we can see in the link below, there is no restriction on what the developer can use in the class attribute.

    http://www.w3.org/html/wg/drafts/html/master/dom.html#classes

    In fact, after saying what the classes are and that they're used spliting in the spaces, the author(s) says:

    There are no additional restrictions on the tokens authors can use in the class attribute, but authors are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content.

    Our colleagues here have tested and it successfully passes W3C validation, so I can't guess why your friend thought it was invalid.

提交回复
热议问题