单引号 vs 双引号 (' vs ") [英] Single vs Double quotes (' vs ")

查看:30
本文介绍了单引号 vs 双引号 (' vs ")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在手动编写 HTML 时总是使用单引号.我使用了很多渲染的 HTML,它们总是使用双引号.这使我能够确定 HTML 是手工编写还是生成的.这是个好主意吗?

I've always used single quotes when writing my HTML by hand. I work with a lot of rendered HTML which always uses double quotes. This allows me to determine if the HTML was written by hand or generated. Is this a good idea?

两者有什么区别?我知道它们都可以工作并且得到所有现代浏览器的支持,但是在不同情况下一个实际上比另一个更好的真正区别是否存在?

What is the difference between the two? I know they both work and are supported by all modern browsers but is there a real difference where one is actually better than the other in different situations?

推荐答案

w3 org :

默认情况下,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. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ".

所以……好像没什么区别.只取决于你的风格.

So... seems to be no difference. Only depends on your style.

这篇关于单引号 vs 双引号 (' vs ")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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