What's the difference?
Dashes, Not Hyphens
And here's a very important rule about dashes: never, never, never use a hyphen in place of a dash. A hyphen is not a junior dash; it has its own completely separate use that I'll talk about some other time, but I can't talk about dashes without telling you not to use hyphens when you should use dashes. It's a common error.
If for some reason you can't insert the dash symbol, use two hyphens right next to each other: hyphen hyphen [--]. If you type two hyphens without any spaces on either side, most word processors will automatically convert them to an em dash. If you put spaces on both sides of the two hyphens, word processors will often automatically convert them to an en dash.
Em Dashes and En Dashes
Huh? What are these em dashes and en dashes of which I speak? An em dash is longer than an en dash. Those may seem like strange names, but they make sense when you realize that traditionally the em dash is as long as the typeset capital letter M and the en dash is as long as the typeset capital letter N.
The em dash is the kind of dash I was talking about before; it is the kind of dash you use in a sentence (1). When people say, “Use a dash,” they almost always mean the em dash.
The en dash is used much less frequently and usually only to indicate a range of inclusive numbers. You would use an en dash to write something like Squiggly will be on vacation December 2 to December 9, where the to between the dates is an en dash and indicates that Squiggly will not be in the office starting the 2nd of December and will return after the 9th of December (because an en dash indicates that the numbers are inclusive of the two dates).
Whether you are using the longer em dash in a sentence or the shorter en dash to indicate an inclusive range, there are no spaces between the dash and the words around it. This is actually a style choice, so you should consult a style guide if your company or teacher has one, but I recommend using no spaces.