HTML Entity for Apostrophe (')

Beginner
6 min read
Updated: Sep 2026
1 example
Unicode U+0027

What Is the Apostrophe Entity?

Apostrophe (') is Unicode U+0027 — the straight ASCII single quote. You use it in contractions (don't), possessives (Sam's), and as the delimiter for single-quoted attributes. HTML provides the named entity '.

Remember
Character     '
Unicode       U+0027
Hex entity    '
Decimal       '
Named entity  '
CSS escape    \0027
Rule          Escape inside single-quoted attributes
Not the same  ’ U+2019 (typographic)

Prefer typing ' in normal UTF-8 text and in double-quoted attributes. Use ' (or ') when the value itself is wrapped in single quotes.

Quick Reference

One table for every form you will actually use.

FormCodeWhere it goes
Direct character'Body text; double-quoted attributes
Named entity'HTML markup (esp. single-quoted attrs)
Hex entity'HTML markup
Decimal entity'HTML markup (widely portable)
CSS escape\0027Stylesheet content
Typographic ’’Polished prose — different character

When to Use Which

SituationUse
Normal paragraph textType ' (or typographic ’)
Attribute in double quotes: title="Don't"Literal ' is fine
Attribute in single quotes: title='Don't'' or '
Generated / ASCII-only markup' or '
CSS ::before / ::aftercontent: "\0027"

Live Preview

Apostrophe rendered from character references and in common phrases.

Contractions don't · it's · we're
Large glyph '
vs. typographic ASCII: ' (U+0027) | Curly: ’ (U+2019)
Monospace O'Brien · McDonald's
All forms Named: ' | Hex: ' | Decimal: '

Complete HTML Example

One page that shows apostrophe with hex, decimal, named entity, CSS escape, and a real phrase. Use View Output or open the live editor.

Hex + Decimal + Named + CSS + Phrase

Five practical ways to produce ' — including a contraction in body text.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Apostrophe (') in HTML</title>
  <style>
    #point::after {
      content: "\0027";
    }
  </style>
</head>
<body>
  <p>Apostrophe using Hex Code: &#x27;</p>
  <p>Apostrophe using HTML Code: &#39;</p>
  <p>Apostrophe using Named Entity: &apos;</p>
  <p id="point">Apostrophe using CSS Entity: </p>
  <p>In a phrase: It&apos;s fine.</p>
</body>
</html>
Try It Yourself

How It Works

1. Hex: U+0027 → &#x27; in HTML. The browser turns it into '.

2. Decimal: same code point as 39 → &#39;. Same result as hex.

3. Named: &apos; is the standard HTML/XML name — clearest when escaping attributes.

4. CSS: use \0027 in content (not an HTML entity). #point::after appends that ' after the paragraph text.

5. Phrase: It&apos;s fine. shows a contraction; you could also type It's in UTF-8 body text.

Pitfalls & Tips

Common mistakes when working with the apostrophe entity.

Attrs

Escape in single-quoted attributes

Write title='Don&apos;t', not a bare ' inside single quotes.

”

ASCII vs curly

' is U+0027. Typographic ’ (U+2019) looks better in prose but is a different character.

CSS vs HTML

Do not mix escapes

\0027 belongs in CSS. &apos; / &#39; belong in HTML.

Quotes

Prefer double-quoted attributes

With title="Don't" you often avoid escaping the apostrophe at all.

&

Also escape ampersands

Reserved siblings: &, ", <.

Semicolon

End references

Always finish with ; — write &apos;, not &apos.

Browser Support

Apostrophe (U+0027) and its entity forms (&apos;, &#39;, &#x27;, CSS \\0027) are supported in all mainstream browsers.

✓ Universal support

Apostrophe (')

Type ', or encode with named, hex, decimal, or CSS escape — same character everywhere.

100% Browser coverage
Google Chrome Supported
Yes
Microsoft Edge Supported
Yes
Mozilla Firefox Supported
Yes
Apple Safari Supported
Yes
Opera Supported
Yes
Internet Explorer All versions
Yes
U+0027 / entities Full support

Bottom line: Type ' in body text and double-quoted attributes. Prefer &apos; or &#39; inside single-quoted attributes, and \\0027 only inside CSS content.

Key Takeaways

  • Unicode: apostrophe is U+0027 (decimal 39).
  • HTML: prefer &apos; or &#39; when escaping.
  • CSS: use \0027 inside content for generated text.
  • Rule: escape ' inside single-quoted attributes.

One line: U+0027 → type ', or encode as &apos; / &#39; / &#x27; / CSS \0027.

Frequently Asked Questions

Use &apos; (named), &#39; (decimal), &#x27; (hex), or the CSS escape \0027 in the content property. All render '. You can also type ' directly in UTF-8 text and in double-quoted attributes.
U+0027 (hex 0027, decimal 39). Unicode names it Apostrophe. It belongs to the Basic Latin (ASCII) block. It is not the same as the typographic right single quotation mark U+2019 (’).
Always escape when the apostrophe appears inside an attribute value wrapped in single quotes — for example title='Don&apos;t'. In normal body text and in double-quoted attributes, a literal ' is usually fine.
Yes. &apos; is defined in HTML5 and XML. Older HTML4 did not list it, so &#39; was the portable numeric form; today &apos; is fine in modern HTML.
HTML entities (&apos;, &#39;, or &#x27;) go in markup. The CSS escape \0027 is used in stylesheets (usually in the content property of ::before/::after). Both render '.
Use U+0027 for code, data, and ASCII-safe markup. Prefer ’ (U+2019) for polished typography in body copy when your fonts and editors support it.

Did you know?

Apostrophe is Unicode U+0027 (decimal 39) — the straight ASCII single quote. HTML provides &apos;. Escape it inside single-quoted attributes so the quote does not end the value early. For typography, many sites prefer the curly mark ’ (U+2019) instead of '.

Next: Approaches the Limit

Learn the HTML entity for the approaches the limit symbol (≐) used in mathematics.

Approaches the Limit tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful