在 XHTML 1.0 Strict 中,属性值是否需要用引号括起来?
示例:
<input type="text" id="username"/>
如果是这样,根据标准是否可以使用单引号并可能与双引号混合使用?
例子:
<input type='text' id="username"/>
最佳答案
From the XHTML 1.0 spec , 它们必须始终被引用。
All attribute values must be quoted, even those which appear to be numeric.
From the HTML 4 spec , 单引号属性是允许的。
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)
上面链接的 xhtml 规范将该部分列为“与 HTML 4 的差异”,因此由于没有明确禁止使用单引号,我认为这意味着也允许使用单引号。
关于xhtml - 在 XHTML 1.0 Strict 中,属性值需要用引号括起来吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5398993/