HTML code for an apostrophe

前端 未结 17 978
独厮守ぢ
独厮守ぢ 2020-11-30 18:01

Seemingly simple, but I cannot find anything relevant on the web.

What is the correct HTML code for an apostrophe? Is it ?

相关标签:
17条回答
  • 2020-11-30 18:28

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

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

    0 讨论(0)
  • 2020-11-30 18:29

    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 ’ (RIGHT SINGLE QUOTATION MARK) and proposes using U+02BC (MODIFIER LETTER APOSTROPHE) (aka ʼ or ʼ) 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
    0 讨论(0)
  • 2020-11-30 18:32

    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.

    0 讨论(0)
  • 2020-11-30 18:32

    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: ', , .

    0 讨论(0)
  • 2020-11-30 18:36

    You can try ' as seen in http://unicodinator.com/#0027

    0 讨论(0)
  • 2020-11-30 18:37

    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 ʼ, rather than ' 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…

    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.

    0 讨论(0)
提交回复
热议问题