在 XHTML 1.0 Strict 中,属性值是否需要用引号括起来? [英] In XHTML 1.0 Strict do attribute values need to be surrounded with quotes?

查看:30
本文介绍了在 XHTML 1.0 Strict 中,属性值是否需要用引号括起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 XHTML 1.0 Strict 中,属性值是否需要用引号括起来?

In XHTML 1.0 Strict do attribute values need to be surrounded with quotes?

例子:

<input type="text" id="username"/>

如果根据标准可以使用单引号,并且可以与双引号混合使用吗?

And if so according to the standard can single quotes be used and possible mixed with double quotes?

例子:

<input type='text' id="username"/>

推荐答案

来自 XHTML1.0 规范,它们必须始终被引用.

From the XHTML 1.0 spec, they must always be quoted.

所有属性值都必须用引号引起来,即使是那些看起来是数字的.

All attribute values must be quoted, even those which appear to be numeric.

<小时>

来自 HTML 4 规范,允许使用单引号属性.


From the HTML 4 spec, single quoted attributes are allowed.

默认情况下,SGML 要求使用双引号(ASCII 十进制 34)或单引号(ASCII 十进制 39)分隔所有属性值

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 的差异",因此由于没有明确禁止使用单引号,我认为这意味着也允许使用单引号.

The xhtml spec linked above lists the section as 'Differences from HTML 4', so since single quotes are not specifically disallowed, I think that means single quotes are allowed as well.

这篇关于在 XHTML 1.0 Strict 中,属性值是否需要用引号括起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆