Wikipedia:Non-breaking hyphen

{{essay|wp:nbhyphen|wp:nb-hyphen|wp:NBHYPHEN}}

This essay explains use of the non-breaking hyphen character , U+2011, coded by ‑ or ‑. Once displayed in a page, the non-breaking hyphen can be copied into words, or abbreviations, so they will not wrap at the hyphen character, such as an interstate highway symbol, "I‑94", which would always wrap to the next line as a whole word.

Not allowed in calculations

Unlike the ASCII hyphen-minus character "-", the non-breaking hyphen character is typically rejected if used as a negative sign or minus sign in calculations:

::* Using hyphen for minus: {{#expr: 34 - 56}} → {{#expr: 34 - 56}}

::* Using non-breaking hyphen: {{#expr: 34 ‑ 56}} → {{#expr: 34 ‑ 56}}

::* Using for minus: {{#expr: 34 − 56}} → {{#expr: 34 − 56}}

Similarly, PC pop-up calculators might typically reject the non-breaking hyphen as a character to be ignored, rather than as a form of minus sign.

Judge if worth possible confusion

When using a non-breaking hyphen, care must be taken to ensure whether other editors would understand the unusual nb-hyphen when used in typical text. Confusion can be eliminated by using the HTML character entity or the template {{tl|nbh}} to insert a non-breaking hyphen.

Search will not match

Whether inserted directly or through use of the template {{tlx|nbh}}, the rendered character, although visually identical, or nearly so (compare:‑-), will not match any search using a standard ASCII hyphen-minus “-”. This is unlike the non-breaking space  , whose rendering on the page is indistinguishable from a regular space. This can be fixed by using a regular hyphen and making it and its bordering words non-breaking with the {{tlx|nowrap}} template (shortcut {{tlx|nobr}}), for example, {{tlx|nowrap|I-94}}. Unfortunately, making only the hyphen nonwrapping has no effect, which precludes redefining the template {{tlx|nbh}} as {{tlx|nowrap|-}}. It will work if a hyphen is followed by {{unichar|2060|WORD JOINER}}, but this character fails to render as zero width as it is supposed to when using the Wikipedia app (only tested on Android) (example: xxx-⁠xxx). This can be fixed by enclosing it in (example: xxx-xxx). Another solution is to follow a hyphen with {{unichar|FEFF|BYTE ORDER MARK}} in its deprecated (since Unicode 3.2) use as {{sc2|{{uc:Zero-width no-break space}}}}. Also usable following a hyphen are   and . All of these satisfy the following three criteria:

  • They prevent post-hyphen breaks.
  • Nothing shows on the page.
  • They are “invisible” to searches.

However, none of these can be used inside wikilinks interchangeably with a standard hyphen. While   links to a standard space, e.g., J.R.R. Tolkien links to J.R.R. Tolkien, both {{unichar|2060}} and {{unichar|FEFF}} are not invisible, I-⁠94 and I-94, while anything with {{tag|span}} in it is not recognized as a wikilink, e.g., I-94. Thus {{tlx|nobr}} must be used outside a non-piped link: {{nobr|I-94}} → {{nobr|I-94}}. If only part of the link text is to be made non-wrapping then a piped link must be used: I-94I-94.

See also