撇号的 HTML 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/419718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML code for an apostrophe
提问by Chris J Allen
Seemingly simple, but I cannot find anything relevant on the web.
看似简单,但我在网上找不到任何相关内容。
What is the correct HTML code for an apostrophe? Is it ’
?
撇号的正确 HTML 代码是什么?是’
吗?
回答by Recep
If you are looking for single quote, it is
如果您正在寻找单引号,那就是
'
回答by mouviciel
A List Apart has a nice reference on characters and typography in HTML. According to that article, the correct HTML entity for the apostrophe is ’
. Example use: ’ .
A List Apart对 HTML 中的字符和排版有很好的参考。根据那篇文章,撇号的正确 HTML 实体是’
. 示例使用: ' 。
回答by paxdiablo
It's '
.
它是'
。
As noted by msanders, this is actually XML and XHTML but not defined in HTML4, so I guess use the '
in that case. I stand corrected.
正如 msanders 所指出的,这实际上是 XML 和 XHTML,但没有在 HTML4 中定义,所以我想'
在这种情况下使用 。我站着纠正。
回答by Joseph Hansen
A standard-compliant, easy-to-remember set of html quotes, starting with the right single-quote which is normally used as an apostrophe:
一组符合标准、易于记忆的 html 引号,从通常用作撇号的正确单引号开始:
- right single-quote —
’
— ’ - left single-quote —
‘
— ‘ - right double-quote —
”
— ” - left double-quote —
“
— “
- 右单引号 —
’
— ' - 左单引号 —
‘
— ' - 右双引号
”
————” - 左双引号
“
————“
回答by Bombe
Depends on which apostrophe you are talking about: there's '
, ‘
, ’
and probably numerous other ones, depending on the context and the language you're intending to write. And with a declared character encoding of e.g. UTF-8 you can also write them directly into your HTML: '
, ‘
, '
.
取决于您在谈论哪个撇号:还有'
, ‘
,’
可能还有许多其他撇号,具体取决于您打算编写的上下文和语言。并且通过声明的字符编码,例如 UTF-8,您还可以将它们直接写入您的 HTML:'
, ‘
, '
.
回答by belugabob
Firstly, it would appear that ' should be avoided - The curse of '
首先,看起来‘ 应该避免 - ' 的诅咒
Secondly, if there is ever any chance that you're going to generate markup to be returned via AJAX calls, you should avoid the entity names (As not all of the HTML entities are valid in XML) and use the &#XXXX; syntax instead.
其次,如果您有机会生成通过 AJAX 调用返回的标记,您应该避免使用实体名称(因为并非所有 HTML 实体在 XML 中都有效)并使用 &#XXXX; 语法代替。
Failure to do so may result in the markup being considered as invalid XML.
否则可能会导致标记被视为无效的 XML。
The entity that is most likely to be affected by this is , which should be replaced by  
最有可能受此影响的实体是 ,应替换为
回答by HammerNL
Note that '
IS defined in HTML5, so for modern websites, I would advise using '
as it is much more readable than '
请注意,'
IS 是在 HTML5 中定义的,因此对于现代网站,我建议使用'
它,因为它比'
Check: http://www.w3.org/TR/html5/syntax.html#named-character-references
检查:http: //www.w3.org/TR/html5/syntax.html#named-character-references
回答by Tom Anderson
Here is a great reference for HTML Ascii codes:
这是 HTML Ascii 代码的重要参考:
http://www.ascii.cl/htmlcodes.htm
http://www.ascii.cl/htmlcodes.htm
The code you are looking for is: '
您正在寻找的代码是: '
回答by WonderWorker
Even though '
reads nicer than '
and it's a shame not to use it, as a fail-safe, use '
.
即使'
读起来更好'
,不使用它也是一种耻辱,作为故障安全,使用'
.
'
is a valid HTML 5entity, however it is not a valid HTML 4entity.
'
是有效的HTML 5实体,但不是有效的HTML 4实体。
Unless <!DOCTYPE html>
is at the top of your HTML document, use '
除非<!DOCTYPE html>
位于 HTML 文档的顶部,否则请使用'
回答by 2540625
I've found FileFormat.info's Unicode Character Searchto be most helpful in finding exact character codes.
我发现FileFormat.info 的 Unicode 字符搜索对于查找准确的字符代码最有帮助。
Entering simply '
(the character to the left of the returnkey on my US Mac keyboard) into their search yields several results of various curls and languages.
简单地输入'
(return我的美国 Mac 键盘上按键左侧的字符)进入他们的搜索会产生各种卷曲和语言的几种结果。
I would presume the original question was asking for the typographically correct U+02BC ?
, rather than the typewriter fascimile U+0027 '
.
我认为最初的问题是要求印刷正确的U+02BC?
,而不是打字机传真U+0027'
。
The W3C recommends hex codes for HTML entities (see below). For U+02BC that would be ʼ
, rather than '
for U+0027.
W3C 推荐 HTML 实体的十六进制代码(见下文)。对于 U+02BC 那将是ʼ
,而不是'
对于 U+0027。
http://www.w3.org/International/questions/qa-escapes
http://www.w3.org/International/questions/qa-escapes
Using character escapes in markup and CSS
Hex vs. decimal.Typically when the Unicode Standard refers to or lists characters it does so using a hexadecimal value. … Given the prevalence of this convention, it is often useful, though not required, to use hexadecimal numeric values in escapes rather than decimal values…
在标记和 CSS 中使用字符转义
十六进制与十进制。通常,当 Unicode 标准引用或列出字符时,它使用十六进制值。...鉴于此约定的普遍性,在转义中使用十六进制数值而不是十进制值通常很有用,尽管不是必需的...
http://www.w3.org/TR/html4/charset.html
http://www.w3.org/TR/html4/charset.html
5 HTML Document Representation… 5.4 Undisplayable characters
…If missing characters are presented using their numeric representation, use the hexadecimal (not decimal) form, since this is the form used in character set standards.
5 HTML 文档表示…… 5.4 不可显示的字符
...如果使用数字表示形式显示缺失字符,请使用十六进制(而非十进制)形式,因为这是字符集标准中使用的形式。