236

看起来很简单,但我在网上找不到任何相关的东西。

撇号的正确 HTML 代码是什么?是’吗?

4

17 回答 17

315
于 2009-01-07T09:36:33.660 回答
106

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: ’ .

于 2009-01-07T09:45:42.223 回答
41

'

正如 msanders 所指出的,这实际上是 XML 和 XHTML,但没有在 HTML4 中定义,所以我想'在这种情况下使用。我站得更正了。

于 2009-01-07T09:35:51.150 回答
19
于 2009-01-07T09:37:13.723 回答
19

A standard-compliant, easy-to-remember set of html quotes, starting with the right single-quote which is normally used as an apostrophe:

  • right single-quote — ’ — ’
  • left single-quote — ‘ — ‘
  • right double-quote — ” — ”
  • left double-quote — “ — “
于 2014-11-17T17:16:52.297 回答
12

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.

Failure to do so may result in the markup being considered as invalid XML.

The entity that is most likely to be affected by this is  , which should be replaced by  

于 2009-01-07T13:05:47.157 回答
6

这是 HTML Ascii 代码的一个很好的参考:

http://www.ascii.cl/htmlcodes.htm

您正在寻找的代码是: '

于 2009-01-07T09:35:57.093 回答
6

Note that ' IS defined in HTML5, so for modern websites, I would advise using ' as it is much more readable than '

Check: http://www.w3.org/TR/html5/syntax.html#named-character-references

于 2013-02-15T12:46:46.007 回答
6

Even though ' reads nicer than ' and it's a shame not to use it, as a fail-safe, use '.

' is a valid HTML 5 entity, however it is not a valid HTML 4 entity.

Unless <!DOCTYPE html> is at the top of your HTML document, use &#39;

于 2017-05-09T14:18:18.847 回答
3

&#39; in decimal.

%27 in hex.

于 2009-01-07T09:37:18.357 回答
3
于 2013-12-01T14:01:48.193 回答
3

I've found FileFormat.info's Unicode Character Search to be most helpful in finding exact character codes.

Entering simply ' (the character to the left of the return key on my US Mac keyboard) into their search yields several results of various curls and languages.

I would presume the original question was asking for the typographically correct U+02BC ʼ, rather than the typewriter fascimile U+0027 '.

The W3C recommends hex codes for HTML entities (see below). For U+02BC that would be &#x2bc;, rather than &#x27; for U+0027.

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…</p>

http://www.w3.org/TR/html4/charset.html

5 HTML Document Representation5.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.

于 2014-09-28T19:07:07.710 回答
3

Just a one more link with nicely maintained collection Html Entities

于 2015-02-06T09:19:23.947 回答
3

Sorry if this offends anyone, but there is a reasonable article on Ted Clancy's blog that argues against the Unicode committee's recommendation to use &#8217; (RIGHT SINGLE QUOTATION MARK) and proposes using U+02BC (MODIFIER LETTER APOSTROPHE) (aka &#700; or &#x2bc;) instead.

In a nutshell, the article argues that:

  • A punctuation mark (such as a quotation mark) normally separates words and phrases, while the sides of a contraction really can't be separated and still make sense.
  • Using a modifier allows one to select a contraction with the regular expression \w+
  • It's easier to parse quotes embedded in text if there aren't quotation marks also appearing in contractions
于 2017-03-20T16:45:52.827 回答
2

As far as I know it is &#39; but it seems yours works as well

See http://w3schools.com/tags/ref_ascii.asp

于 2009-01-07T09:38:36.747 回答
2

Use &apos; for a straight apostrophe. This tends to be more readable than the numeric &#39; (if others are ever likely to read the HTML directly).

Edit: msanders points out that &apos; isn't valid HTML4, which I didn't know, so follow most other answers and use &#39;.

于 2009-01-07T09:40:51.530 回答
1

You can try &#x0027; as seen in http://unicodinator.com/#0027

于 2014-04-12T16:34:25.237 回答