URLs and paths require special word-breaking rules

Hyphenation can introduce hyphens into a URL or file path when breaking it across multiple lines. It will be unclear, however, whether or not the hyphen is meant to be part of the URL or file path. The guidelines I follow are primarily inspired by the ones in the Yahoo! Style Guide (now archived):

In HTML and CSS, set URLs and file paths to never break, with hyphens: never. Convert hyphens to non-breaking hyphens, and spaces to non-breaking spaces. Manually insert the empty <wbr> (word break) element at word-break opportunities, i.e., before slashes, periods, and hyphens. <wbr> creates word breaks without hyphens, which is ideal for URLs and file paths. For more details, refer to the hyphens CSS property reference on MDN, or the wbr HTML element reference on MDN.

This web site follows these guidelines. For example: ~/Library/Application Support/My app/ws.denis.something.a.giant.period.separated.string.that.is.almost.too.long/supercalifragilisticexpialidocious/a very long piece of text indeed that should definitely certainly not be broken/antidisestablishmentarianism/some‑overly‑long‑hyphenated‑piece‑of‑text‑that‑should‑also‑not‑be‑broken/and/we/are/at/the/end.

This might look weird, and be at odds with grammar rules, but Grammar must serve communication.

Note last edited November 2023.