What many people call a dash is actually a hyphen. A hyphen has no spaces around it, except when it is used to indicate a “minus” sign.
The hyphen is an oft-used punctuation mark in saying 7 – 4 = 3.
There are two other types of dashes: the en dash and the em dash (named by typographers for being as long as an n and an m, respectively).
The em dash is used most often; it indicates a separate thought and can be indicated on computers by two hyphens–like this.
The en dash is almost never needed by authors and can be indicated on a computer using a hyphen. It is used in formal typography to indicate a span, such as 1999-2001. (Notice that I used a hyphen.)