A hyphen (-) shows that the matter it is attached to is not a complete word by itself. It should not be used with a space at both ends, although sometimes it is appropriate for it to have a space at one end.
The use of hyphens is often a matter of style. But they are used to do the following things:
- join compound words
- join compound modifiers
- attach prefixes
- indicate a piece of a word
- indicate a word break at the end of a line
You might have heard of soft hyphens and hard hyphens. Soft hyphens are those that indicate word division at the end of a line. Hard hyphens are those that indicate words or parts of words are joined together to form compounds. There’s no difference in size or shape.
Hyphens are also used to indicate stammering or paused speech:
'W-w-what are we to do?'
And they indicate the omission of the second part of a hyphenated expression or solid compound:
three- and five-door cars over- and underpaid employees
If you would like to find out more about when to use a hyphen, I can recommend the Penguin Guide to Punctuation for a thorough and simple explanation.