Is it correct to use single quotes for HTML attributes?

前端 未结 15 2725
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 05:57

Recently I\'ve been seeing a lot of this:


    

        
15条回答
  •  不知归路
    2020-12-01 06:40

    If you want to the html to be valid html4 or xhtml then both single-quotes or double-quotes will work for attributes. HTML4 can be validated here: https://validator.w3.org/

    If you are supporting only modern browsers (ie10 and higher) then you can use the html5 syntax which allows single quotes, double quotes, and no quotes (as long as there are no special characters in the attributes' value). HTML5 can be validated here: https://validator.w3.org/nu

提交回复
热议问题