whitespace nowrap on span

54.2k views Asked by At

In this case:

<td>
       Some Text
       <span class="Icon"></span>
</td>

I want to get the line break when necessary on my Text but I don't want my span to get on a new line, I want it to always stick to part of the text. How can I do it?

Thanks,

2

There are 2 answers

0
Jukka K. Korpela On

Replace all whitespace before the span with a single no-break space (if you want some spacing to appear between your text and whatever rendering you have styled for the span; if no spacing is desired, omit the &nbsp; ).

<td>
       Some Text&nbsp;<span class="Icon"></span>
</td>
0
Mina On

How I solved my problem by putting one span into the other:

<table style="width:100px">
<tr>
    <td>
        I am Showing you what <span style=" white-space: nowrap;">I meant
        <span> Blah Blah </span></span>
    </td>

</tr>

Check JSFiddle.