Automatic Hyphenation for Long-Word Languages
Turns on the browser's built-in hyphenation for post content in languages with long compound words, such as German, Dutch and Finnish, so narrow columns on phones stop showing large gaps.
Opens WPIDE on
Code
:lang(de) .entry-content p,
:lang(nl) .entry-content p,
:lang(fi) .entry-content p,
:lang(sv) .entry-content p,
:lang(da) .entry-content p,
:lang(nb) .entry-content p,
:lang(hu) .entry-content p,
:lang(de) .wp-block-post-content p,
:lang(nl) .wp-block-post-content p,
:lang(fi) .wp-block-post-content p {
-webkit-hyphens: auto;
hyphens: auto;
hyphenate-limit-chars: 8 3 3;
overflow-wrap: break-word;
}
Notes
Hyphenation follows the page's lang attribute, so make sure it is set correctly. Headings are left alone.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.