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

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

问题描述

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

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

推荐答案

来自XHTML 1.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天全站免登陆