Add non-breaking space between an image and a word

You may want a certain image to remain always in the same line with one or more words. The usual non breaking space HTML tag ( ) works only between words, not between an image and a word.

Remember this ghost tag, <nobr>! It won’t work either! No joy to try also adding this CSS property, white-space:nowrap.

There is a CSS way to go, a simple one, the inline-block display property, which you can have in span tags as it is, or by defining a class, in case you need this image+text element often.

For example,

<span style="display:inline-block;"><your whatever IMG tag> AnyWord</span>.

In this example, “AnyWord” remains at the right of an image always; the space that precedes it won’t ever make it sink to a different line.