如何通过HTML代码编写双引号

时间:2021-12-28 22:29:06

In HTML, What is the preferred way to specify html codes like ", and what is the major differences? For example:

在HTML中,指定HTML代码的首选方式是什么,主要的区别是什么?例如:

&quot;    <!-- friendly code -->
&#34;     <!-- numerical code -->
&#x22;    <!-- hex code -->

Which one should I use and would it ever be an issue if one of these gets deprecated?

我应该使用哪一个,如果其中一个被弃用了会不会成为问题?

3 个解决方案

#1


50  

There really aren't any differences.

真的没有什么区别。

&quot; is processed as &#34; which is the decimal equivalent of &x22; which is the ISO 8859-1 equivalent of ".

“;是加工& # 34;这个小数等于&x22;也就是ISO 8859-1的“”。

The only reason you may be against using &quot; is because it was mistakenly omitted from the HTML 3.2 specification.

你可能反对使用“;因为它在HTML 3.2规范中被错误地忽略了。

Otherwise it all boils down to personal preference.

否则,一切都归结为个人偏好。

#2


7  

Google recommend that you don't use any of them, source.

谷歌建议您不要使用它们中的任何一个,源代码。

There is no need to use entity references like &mdash, &rdquo, or &#x263a, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.

没有必要使用诸如&mdash、&rdquo或☺这样的实体引用,假设文件和编辑器以及团队之间使用相同的编码(UTF-8)。

Is there a reason you can't simply use "?

有什么原因让你不能简单地使用它吗?

#3


2  

There is no difference, in browsers that you can find in the wild these days (that is, excluding things like Netscape 1 that you might find in a museum). There is no reason to suspect that any of them would be deprecated ever, especially since they are all valid in XML, in HTML 4.01, and in HTML5 CR.

在如今的浏览器中,你可以发现没有什么不同(也就是说,不包括你可能在博物馆里找到的Netscape 1之类的东西)。没有理由怀疑它们中的任何一个会被废弃,特别是因为它们在XML、HTML 4.01和HTML5 CR中都是有效的。

There is no reason to use any of them, as opposite to using the Ascii quotation mark (") directly, except in the very special case where you have an attribute value enclosed in such marks and you would like to use the mark inside the value (e.g., title="Hello &quot;world&quot;"), and even then, there are almost always better options (like title='Hello "word"' or title="Hello “word”".

没有理由使用其中任何一个,相反,使用Ascii引号(“),除了在非常特殊的情况下,您有一个属性值包含在这样的标志和你想使用内部的标志值(例如title =“你好“world"”),即使这样,有几乎总是更好的选择(比如title =“你好”“”或title =“Hello”字”。

If you want to use “smart” quotation marks instead, then it’s a different question, and none of the constructs has anything to do with them. Some people expect notations like &quot; to produce “smart” quotes, but it is easy to see that they don’t; the notations unambiguously denote the Ascii quote ("), as used in computer languages.

如果您想使用“智能”引号,那么这是一个不同的问题,而且这些构造都与它们没有任何关系。有些人期望有“;生产“聪明”的引语,但很容易看到他们没有;表示法明确地表示Ascii引号(”),如在计算机语言中使用。

#1


50  

There really aren't any differences.

真的没有什么区别。

&quot; is processed as &#34; which is the decimal equivalent of &x22; which is the ISO 8859-1 equivalent of ".

“;是加工& # 34;这个小数等于&x22;也就是ISO 8859-1的“”。

The only reason you may be against using &quot; is because it was mistakenly omitted from the HTML 3.2 specification.

你可能反对使用“;因为它在HTML 3.2规范中被错误地忽略了。

Otherwise it all boils down to personal preference.

否则,一切都归结为个人偏好。

#2


7  

Google recommend that you don't use any of them, source.

谷歌建议您不要使用它们中的任何一个,源代码。

There is no need to use entity references like &mdash, &rdquo, or &#x263a, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.

没有必要使用诸如&mdash、&rdquo或☺这样的实体引用,假设文件和编辑器以及团队之间使用相同的编码(UTF-8)。

Is there a reason you can't simply use "?

有什么原因让你不能简单地使用它吗?

#3


2  

There is no difference, in browsers that you can find in the wild these days (that is, excluding things like Netscape 1 that you might find in a museum). There is no reason to suspect that any of them would be deprecated ever, especially since they are all valid in XML, in HTML 4.01, and in HTML5 CR.

在如今的浏览器中,你可以发现没有什么不同(也就是说,不包括你可能在博物馆里找到的Netscape 1之类的东西)。没有理由怀疑它们中的任何一个会被废弃,特别是因为它们在XML、HTML 4.01和HTML5 CR中都是有效的。

There is no reason to use any of them, as opposite to using the Ascii quotation mark (") directly, except in the very special case where you have an attribute value enclosed in such marks and you would like to use the mark inside the value (e.g., title="Hello &quot;world&quot;"), and even then, there are almost always better options (like title='Hello "word"' or title="Hello “word”".

没有理由使用其中任何一个,相反,使用Ascii引号(“),除了在非常特殊的情况下,您有一个属性值包含在这样的标志和你想使用内部的标志值(例如title =“你好“world"”),即使这样,有几乎总是更好的选择(比如title =“你好”“”或title =“Hello”字”。

If you want to use “smart” quotation marks instead, then it’s a different question, and none of the constructs has anything to do with them. Some people expect notations like &quot; to produce “smart” quotes, but it is easy to see that they don’t; the notations unambiguously denote the Ascii quote ("), as used in computer languages.

如果您想使用“智能”引号,那么这是一个不同的问题,而且这些构造都与它们没有任何关系。有些人期望有“;生产“聪明”的引语,但很容易看到他们没有;表示法明确地表示Ascii引号(”),如在计算机语言中使用。