— is the HTML entity for the em dash —, U+2014 EM DASH, and — and — are its numeric references. In UTF-8 it’s E2 80 94.
Character — U+2014 EM DASH
Named —
Numeric — —
UTF-8 E2 80 94
Encoding It works—mostly. gives It works—mostly.
Which dash
- U+002D hyphen-minus compound words, line-end hyphens, code
– U+2013 en dash – ranges: 10–12, Mon–Fri
— U+2014 em dash — a break in a sentence
− U+2212 minus sign − negative numbers and subtraction in text
The em dash sets off an aside or a sudden turn, as parentheses or a colon would, with more force. Spacing is a house style: The Chicago Manual of Style closes it up (works—mostly), and AP style puts a space on each side (works — mostly). British publishers often use a spaced en dash for the same job.
Browsers may break a line before or after an em dash, as Unicode’s line-breaking rules (UAX #14) allow; in a 7-character-wide box, Chromium and WebKit both put aaaa—bbbb on two lines. If you use spaced dashes, a before the dash keeps a line from starting with one.
Why write the entity
In a UTF-8 page the raw — is fine. The entity’s advantage is legibility: in a monospace editor —, – and - are easy to mix up, and — and – aren’t. Two hyphens are not a dash in HTML; SmartyPants-style typographers, such as markdown-it with typographer on, turn --- into — and -- into –, and plain CommonMark leaves them alone.
Old pages often contain —. That’s 0x97, a C1 control character, but Windows-1252 put the em dash there, so the HTML standard tells browsers to show — and report a parse error. This tool decodes it the same way; write — in new markup.
In CSS, JSX and Markdown
blockquote footer::before { content: "\2014\a0"; } /* an em dash, then a no-break space */
JSX decodes — in text and in quoted attributes. In braces it’s JavaScript, so {'—'} prints the entity’s letters; write {'\u2014'} or the character. CommonMark decodes — in Markdown text and leaves it literal in code spans and code blocks.