THE GITHTML FIELD GUIDE

Use language-aware hyphenation in narrow HTML paragraphs

Enable automatic hyphenation selectively for ordinary prose and declare the passage's language. Hyphenation depends on browser support and available language dictionaries, so preserve a readable layout when it does not occur. Keep identifiers, commands, and values that must be copied exactly out of the hyphenated style.

Choose the right representation

A narrow paragraph containing long words can develop large gaps or force awkward wrapping. Language-aware hyphenation can help prose use the available width more evenly. It is not a substitute for a sensible reading measure, and it should not be used to disguise a container that is too narrow for its content.

Apply the pattern deliberately

Apply the rule to prose blocks, not universally to every element. Give differently written passages their appropriate language metadata. A dictionary for one language should not be expected to divide a technical term from another correctly. For codes and machine identifiers, use a wrapping strategy that does not visually suggest extra characters.

  1. Set the correct language on the document and on passages that change language.
  2. Scope automatic hyphenation to ordinary explanatory prose, excluding exact-copy technical strings.
  3. Review line endings manually for terms whose split could confuse their intended meaning.
html
<article lang="en" class="prose">...</article>
<style>.prose { hyphens: auto; } .prose code { hyphens: none; }</style>

Diagnose the word before forcing a break

First decide whether the troublesome string is a natural-language word, a URL, or an identifier. A dictionary can help divide a prose word; it cannot know where your internal service identifier should break. Give exact-copy strings their own treatment and keep their authoritative spelling intact. If a long word is actually an unexplained abbreviation or product name, defining it once may help comprehension more than forcing it into a narrow column.

Automatic hyphenation needs suitable language information and implementation support. An English page containing a paragraph in another language should mark that passage appropriately instead of inheriting the wrong language by accident. Do not use a successful screenshot from one computer as proof that every operating system has the same dictionary. Inspect the unhyphenated layout too: if it becomes unusable, widen the prose measure or revise the layout instead of making a dictionary an undocumented requirement.

Be cautious with manually inserted soft hyphens. They may be useful when an author knows an appropriate break, but invisible characters can complicate searching and copying technical material. Keep them away from executable examples and identifiers unless you have verified the resulting text. For a multilingual report, ask a fluent reviewer to inspect surprising divisions and confirm that the intended word remains recognizable. The goal is easier reading, not making every line occupy exactly the same width.

Check the finished reading experience

Inspect a real paragraph containing several long words rather than a repeated placeholder sentence. Check both the hyphenated and unhyphenated result. Readers may use a different operating system or language configuration, and a document should remain readable without matching the author's exact line endings.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All reading html on your phone guides →

Read as MarkdownAll guides

Use language-aware hyphenation in narrow HTML paragraphs · gitHtml