brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: hyphens: auto breaks long Dutch words, as long as lang is set

Web-Development
~/tips/tip-css-hyphens-auto-lang

hyphens: auto;

Lets the browser hyphenate long words at the end of a line, using the page language.

Dutch is a language of very long words. Put arbeidsongeschiktheidsverzekering in a narrow column on a phone and it either sticks out of the box or leaves a huge gap on the line above. Living in Leiden and reading plenty of Dutch on an iPhone, I’d turn on hyphens: auto on any Dutch text column.

It needs two things: the property in your CSS and the right language in your HTML.

<html lang="nl">

p, li {
  hyphens: auto;
}

With auto the browser looks up where a word may be split and adds a hyphen at the end of the line when the word doesn’t fit. The rules are per language, and the browser takes the language from the lang attribute. No lang, no hyphens. A Dutch article on a site that says lang="en" gets English rules, so a page that mixes languages should set lang on the parts that differ.

You can also suggest break points yourself with a soft hyphen, &shy;. It’s invisible until the word gets split there, and it beats the automatic choice when both are present:

<h2>Arbeids&shy;ongeschiktheids&shy;verzekering</h2>

That’s the one I’d use for headings, where you want control over where a word breaks. The default value, manual, only breaks at soft hyphens and real hyphens in the text.

The caveat is that hyphenation depends on the browser having a dictionary for the language, and MDN marks the support with an asterisk: it differs per browser and, for older Chrome versions, per platform. So treat it as a nice extra. Also, word-break: break-all breaks words without showing any hyphen, so don’t combine them. The property itself is Baseline widely available since March 2026, now that Safari 17 supports it without the -webkit- prefix.

Further reading: MDN: hyphens, MDN: lang attribute

More Web-Development tips ab -n 200 -c 10 https://example.com/ console.assert(items.length > 0, 'cart is empty', items) document.designMode = "on" function save(item) { Save draft All Web-Development tips (67) All topics

Link