# Avoid spaces before or after a dash (EK00028)

import { Aside, Badge } from '@astrojs/starlight/components';

American English style sets an em dash or en dash tight against the surrounding words, so remove any space before or after it. EkLine flags a space placed around these dashes (rule EK00028).

## Why remove spaces around a dash in documentation?

An em dash or en dash reads as a firm break, and spaces around it weaken that effect and look inconsistent across a page. Tight dashes match the American English convention most software documentation follows. Uniform dash spacing also keeps diffs clean and prevents awkward line wraps.

## What EkLine flags

EK00028 matches a space directly before or after an em dash or en dash.

- ❌ **Incorrect:** The result — a clean build — appears in the log.
- ✅ **Correct:** The result—a clean build—appears in the log.
- ❌ **Incorrect:** Pages 10 – 20 cover setup.
- ✅ **Correct:** Pages 10–20 cover setup.

## How to fix

Delete the spaces on either side of the dash so it sits flush against the adjacent words.

<Aside type="note">
Some style guides — such as AP style — set em dashes with surrounding spaces on purpose. When your house style requires spaced dashes, keep them and ignore the rule for that line.
</Aside>

## FAQ

### Should there be spaces around an em dash?

In American English, no. Set the em dash tight against the words on both sides, as in "the result—a clean build—appears". Some styles, such as AP, add spaces, so follow your house style.

### What is the difference between an em dash and an en dash?

An em dash (—) marks a break or aside within a sentence, while the shorter en dash (–) joins ranges and numbers. Neither takes surrounding spaces in American English style.

## Rule details

| Property | Value |
|----------|-------|
| Rule ID | `EK00028` |
| Category | Spelling and grammar |
| Default severity | <Badge text="Error" variant="danger" /> |
| Enabled by default | No |

## Ignore this rule

To keep a spaced dash on one line, add an inline comment:

```markdown
<!-- ekline-ignore-next-line EK00028 -- AP style uses spaced em dashes -->
The result — a clean build — appears in the log.
```

To disable the rule across your project, add it to the `ignore` list in your [configuration file](/reviewer/configuration/ignoring-rules/#ignore).

## Related rules

- [EK00032](/reviewer/rules/ek00032/) — Use an em dash instead of an en dash
- [EK00034](/reviewer/rules/ek00034/) — Use an en dash for negative numbers