tags:

views:

84

answers:

3

Hello, 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.

+10  A: 

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; }
cletus
I considered that, but I figured it would cause an unnecessary scroll bar, but it doesn't. Thanks!
Earlz
+1  A: 

white-space:nowrap;

For more information, see: CSS nowrap alternative.

Justin Ethier
+2  A: 

Use white-space: nowrap;.

Joachim Sauer