What is the difference between a hyphen, an en dash and an em dash?
Three marks of different lengths doing three different jobs. Most writing uses only the first, which is why the others look unfamiliar.
Hyphen ( - ) — the shortest, and the one on the keyboard. It joins words. Well-known author. Twenty-three. Mother-in-law. It also splits a word across a line break.
The useful rule for compound adjectives: hyphenate when the words work together to modify a noun before it. A well-known author, but the author is well known. This resolves real ambiguity — a small business owner and a small-business owner mean different things.
En dash ( – ) — the width of a capital N. It indicates a range or a connection between two things. Pages 34–58. The 2019–2020 season. The London–Paris route. The Bose–Einstein condensate. When used for a range it means "to", so writing from 1990–1995 is redundant; use from 1990 to 1995 or just 1990–1995.
Em dash ( — ) — the width of a capital M. It marks a break in a sentence, more emphatic than a comma and less formal than parentheses. The result — and nobody expected this — was unanimous. A single em dash can also introduce a conclusion: There was only one option left — retreat.
Style varies on spacing. American style typically sets em dashes closed up; British style often uses a spaced en dash for the same purpose.
On a Mac, en dash is Option-hyphen and em dash is Shift-Option-hyphen. On Windows, Alt+0150 and Alt+0151. Most word processors also convert two hyphens automatically.
One convention that catches people out: do not hyphenate a compound where the first word ends in -ly. A badly written report, not a badly-written report — the -ly already signals that the adverb modifies the adjective, so the hyphen adds nothing.