You see it both ways so often that its inconsistency has become consistent, but it still gets under your skin. Should an em dash (—) have spaces before and after it, or should it touch the words it separates?
First, what is an em dash? An em dash can be used in pairs to encompass a word, phrase or clause within a sentence. They can also be used to separate one part of a sentence from the main body, and they are particularly useful in long, complex sentences.
As for spacing, it depends on the style your organization uses.
AP Style: Em dashes should always have a space before and after:
As Chad thought about making an appointment for his annual health screening — and the deadline was swiftly approaching — he hoped he would surpass his weight-loss goal for the year.
The vast majority of all other style guides, including Chicago style: Em dashes should never have a space before or after:
As Chad thought about making an appointment for his annual health screening—and the deadline was swiftly approaching—he hoped he would surpass his weight-loss goal for the year.
—Sarah Muench