When to use it
Escape it as ' or ' inside single-quoted attributes. ' is valid in HTML5 and XML but not in old HTML 4.
In HTML, CSS and JavaScript
<p>'</p> <!-- or the character itself in a UTF-8 page -->
.note::before { content: "\0027"; }
const s = "\u0027";
In a page saved as UTF-8 (the default today) you can paste the character directly; the entity is only needed when it must survive a non-UTF-8 system, or — as here — when the character has a special meaning in HTML. Encode or decode whole texts with the HTML Entity Encoder.
How to type apostrophe (straight)
- Windows: press Win + . to open the emoji and symbol panel and search for it, or type
0027then Alt + X in Word. - Mac: press Ctrl + Cmd + Space and search for “apostrophe (straight)”.
- Linux: Ctrl + Shift + U, then 27 and Enter.
HTML Entity EncoderEscape < > & " so text is safe to show in HTML, convert accents and symbols to named or numeric entities, or decode entity-filled HTML back to plain text.
Open the tool Frequently asked questions
What is the HTML code for the apostrophe (straight)?
' (named), ' (decimal) or ' (hex). All three produce the same character.
What is the Unicode for the apostrophe (straight)?
U+0027. In CSS write "\0027" and in JavaScript "\u0027".
How do I type the apostrophe (straight) on a keyboard?
On Windows open the symbol panel with Win + . and search for it. On a Mac use Ctrl + Cmd + Space and search for it.