Dashes are longer than hyphens, but since older browsers do not reliably interpret the code for dashes, they are usually rendered on the Web as they were on old-fashioned typewriters, as double hyphens–like that. Dashes tend to separate elements and hyphens to link them. Few people would substitute a dash for a hyphen in an expression like “a quick-witted scoundrel,” but the opposite is common. In a sentence like “Astrid—unlike Inger—enjoyed vacations in Spain rather than England,” one often sees hyphens incorrectly substituted for dashes.
When you are typing for photocopying or direct printing, it is a good idea to learn how to type a true dash instead of the double hyphen (computers differ). In old-fashioned styles, dashes (but never hyphens) are surrounded by spaces — like this. With modern computer output which emulates professional printing, this makes little sense. Skip the spaces unless your editor or teacher insists on them.
There are actually two kinds of dashes. The most common is the “em dash” (theoretically the width of a letter “M”—but this is often not the case). To connect numbers, it is traditional to use an “en dash” which is somewhat shorter, but not as short as a hyphen: “cocktails 5–7 pm.” All modern computers can produce en dashes, but few people know how to type them. For most purposes you don’t have to worry about them, but if you are preparing material for print, you should learn how to use them.
In HTML, the code for an em-dash is — and – is the code for an en-dash.