什么是单引号VS双引号括起来的HTML属性之间的功能差异? [英] What are the functional differences between single-quoted vs double-quoted html attributes?

查看:231
本文介绍了什么是单引号VS双引号括起来的HTML属性之间的功能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sEncodedHref 表示 HttpUtility.HtmlAttributeEncode(..)'D弦。

是否有这样生成的html之间的功能差异:

Are there any functional differences between generated html like this:

String.Format(@"<span class='blue' src='{0}'>", sEncodedHref);



VS。生成的html是这样的:

vs. generated html like this:

String.Format(@"<span class=""blue"" src=""{0}"">", sEncodedHref);



我一直的印象是单引号变种均不支持少安全下不过我有麻烦提供理由支持这样的说法。

I've been under the impression that the single-quoted variant is both less supported and less "safe", however I have trouble providing reasons to support that argument.

推荐答案

有没有功能上的差异。 报价在SGML和HMTL W3C的:

There is no functional difference. Quoting the W3C on SGML and HMTL:

默认情况下,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). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa.

...

在某些情况下,作者可以在没有任何引号指定属性的值。该属性值只能包含字母(A-Z和A-Z),数字(0-9),连字符(ASCII十进制45),时间(ASCII十进制46),下划线(ASCII十进制95)和冒号(ASCII十进制58)。我们建议使用引号,即使它是可能的,以消除它们

In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.

这篇关于什么是单引号VS双引号括起来的HTML属性之间的功能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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