views:

167

answers:

3

This should be fairly simple, but I have not been able to find anything usefull when google-ing.
What I have is some text and some icons that I want to ensure that stays on the same line. For example I want this:

Text goes here and eventually we run into the end of the line [text][icon]

or this:

Text goes here and eventually we run into the end of the line 
[text][icon]

but not this:

Text goes here and eventually we run into the end of the line [text]
[icon]

The only thing I've been able to come up with when google-ing is that apparently IE has some problems implementing this. I don't really care if IE is able to do it or not (at least not yet), I just want to find a solution... :)

+2  A: 

Put it in a container with no-wrap specified for the whitespace property in the stylesheet.

Azeem.Butt
I added this to the code:(...)<div style="white-space: no-wrap">[text][icon]</div>What happened was that the text broke to a new line on every whitespace outside of the div. Am I doing something horribly wrong?
Paul
Use an inline element like a span rather than a div.
Azeem.Butt
Changed it to a span, but it's still the same
Paul
Then your container is either too small to avoid breaking that line in the first place or your stylesheets have problems.
Azeem.Butt
A: 

Consider using the non-breaking space &nbsp; instead of space between the last word(s) and the icon.

For example:

Text goes here and eventually we run into the end of the line [text]&nbsp;[icon]

instead of

Text goes here and eventually we run into the end of the line [text] [icon]
BalusC
Problem is that there's no whitespace between the text and the image and it still breaks. It does too if I add  
Paul
+2  A: 

You need to use non-breaking spaces, coded &nbsp; to prevent breaks in the spaces between.

Peter