xhtml - 在 XHTML 1.0 Strict 中,属性值需要用引号括起来吗?

标签 xhtml attributes tags xhtml-1.0-strict

在 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/

相关文章:

attributes - 如何在 UML 属性中指定枚举文字作为默认值?

javascript - 如何在每个类中找到 href 属性?

javascript - 获取 HTML 元素的完整(原始)文本

json - 同一个 Go 结构成员上的多个标签

android - 解析 XML 时出错 : Mismatched tag - Android strange error

Javascript 动态更改另一个页面,这是我正在尝试做的可能吗?

xhtml - 防止浏览器插入名称和密码

html - 如何阻止 ORBIS CMS 自动插入 <p> 标签

css - 三列固定宽度的 Web 布局和古怪的刷新行为

javascript - 从 XML 文件中提取属性?