Creating a piece of text without breaking?

Say I have a text like this

Hi, I'm a little text. Hi, I'm a little text. Hi, I'm a little text. Hi, I'm some text. I don't want to be broken on new lines.

Consider the paragraph above. I want the bold part not to be broken in a new line, if possible. Like in, I want it to break if you need a scroll bar or something like that, but it won't break if you can insert a page break before or after this piece of text so that it can fit on one line.

How is this possible? I tried things like page-break-inside etc., but it does nothing in firefox.

+41
html css nowrap
Mar 01 '10 at
source share
2 answers

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> 

from:

 span.nobr { white-space: nowrap; } 
+84
Mar 01 '10 at 22:11
source share

Adding this for completeness:

If you don't want to use CSS, you can use <nobr>text with space</nobr> - reference here

For pure text blocks, I believe that html formatting tags that are no longer tags, such as <i> , <b> , <nobr> and the like, are valid for use. For content related to site structure , use <em> , <strong> and <span class=""> .

+11
May 13 '14 at 14:30
source share



All Articles