Search code examples
htmlcssword-break

Is it possible to prevent linebreaks between hyphenated words in CSS?


While CSS has word-break to better control display of long words, is it possible to do the reverse by preserving hyphenated words without been forcefully broken into 2 separate lines?

CodePen Demo to better illustrate the scenario.


Solution

  • Did you try using "non-breaking hyphen"? No CSS needed. It's a normal html entity.

    Try this ‑

    This is an example

    Sample‑text