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

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

问题描述

手工编写我的HTML时,我总是使用单引号。我使用了大量经常使用双引号的HTML。这使我可以确定HTML是手写还是生成。这是个好主意吗?



两者有什么区别?我知道它们都可以工作,并且受到所有现代浏览器的支持,但是在不同情况下,哪一个实际上比另一个更好?解决方案 div>

w3 org 表示


默认情况下,SGML要求使用双引号(ASCII小数点34)或单引号(ASCII十进制39)。当值由双引号分隔时,单引号可以包含在属性值中,反之亦然。作者也可以使用数字字符引用来表示双引号(" )和单引号(' )。对于双引号,作者还可以使用字符实体引用& quot;



<所以...似乎没有区别。只取决于你的风格。


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?

解决方案

The w3 org said:

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 (&#34;) and single quotes (&#39;). For double quotes authors can also use the character entity reference &quot;.

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

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

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