简体   繁体   English

撇号是HTML元素属性值的有效容器吗?

[英]Are apostrophes valid containers for HTML element attribute values?

Usually HTML element attribute values are marked with a quotation mark, like 通常HTML元素属性值用引号标记,如


<input type="hidden" value="test" />

Sometimes, however, you see code like 但是,有时您会看到类似的代码


<input type='hidden' value='test' />

Is it valid HTML and can it cause any problems? 它是有效的HTML,它会导致任何问题吗? What about mixing the two, like 怎么样混合两者,比如


<input type='hidden' value="test">

?

The linked question from James Allardice's comment to my original question lead me to the answer: yes, apostrophes are valid containers for HTML element attribute values. James Allardice对我原始问题的评论中的链接问题引出了我的答案:是的,撇号是HTML元素属性值的有效容器。

Specification: On SGML and HTML 规范: 关于SGML和HTML

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). 默认情况下,SGML要求使用双引号(ASCII十进制34)或单引号(ASCII十进制39)分隔所有属性值。 Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. 当值由双引号分隔时,单引号可以包含在属性值中,反之亦然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM