// denisdefreyne.com / notes

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.very.long.period.separated.string/more/and/more/slashes/infinite/slashes/some text that should not be broken/hyphenated‑text‑that‑should‑not‑be‑broken/lorem ipsum dolor sit amet/lorem ipsum indeed.

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