Making a piece of text non-breaking?

HtmlCssNowrap

Html Problem Overview


say I have a piece of text like this

> Hello I am some text Hello I am some > text Hello I am some text Hello I am > some text I do not wish to be broken > on new lines

Consider the above paragraph. I want for the bolded part to not be broken across a new line if possible. As in, I want it to break if it would require a scrollbar or something, but not break if it is possible to insert a page-break before or after that piece of text so that it can fit on one line.

How is this possible? I have tried things like page-break-inside and such, but it doesn't seem to do anything in firefox.

Html Solutions


Solution 1 - Html

Use the white-space property:

Hello I am some text Hello I am some text Hello I am some text
Hello I am some text <span class="nobr">I do not wish to be
broken on new lines</span>

with:

span.nobr { white-space: nowrap; }

Solution 2 - Html

Adding this for completeness:

If you do not want to use CSS, you could use <nobr>text with space</nobr> - reference here

For pure text blocks, i believe not-anymore-depricated html formatting tags like <i>, <b>, <nobr> and alike are valid for use. For content relating to the site structure use <em>, <strong> and <span class="">.

Solution 3 - Html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEarlzView Question on Stackoverflow
Solution 1 - HtmlcletusView Answer on Stackoverflow
Solution 2 - HtmlBananaAcidView Answer on Stackoverflow
Solution 3 - HtmlYevgeniy AfanasyevView Answer on Stackoverflow