Let sEncodedHref
represent an HttpUtility.HtmlAttributeEncode(..)
'd string.
Are there any functional differences between generated html like this:
String.Format(@"<span class='blue' src='{0}'>", sEncodedHref);
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.
There is no functional difference. Quoting the W3C on SGML and HMTL:
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.
...
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.
Absolutely no functional difference. Both are valid, although double quotes are more widely used and are preferred.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With