Avoid to split two words in HTML or CSS

Posted on November 9, 2021

Here the handy tip to avoid that two or more words are split in the paragraph.

Using the HTML only:

<p>
  These two&nbsp;words need to be in the same line
</p>

or with CSS:

<p>
  These <span class="together">two words</span> need to be in the same line
</p>
span.keeptogether {
  white-space: nowrap;
}