title: Prevent line break between last word of an element and another element
body: <p>Given an inline (or inline-block) element with text of variable length, and another element to the right of the first one that acts as a kind of badge, is there a way to prevent a line break between the last word of the first element and the second element? Both elements occupying the same line is fine; a line break occurring in the text of the first element is also fine; but a line break between the two elements is undesirable. Here is an illustration explaining what I mean.</p>
  
  <p><a href="https://i.stack.imgur.com/zAeBl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zAeBl.png" alt="line break diagram"></a></p>
  
  <p>Is there a way to do this? I tried to have the two elements as spans and put a non-breaking space between them, but that didn't work.</p>
  
  <p><strong>UPDATE:</strong> Here's a quick and dirty Codepen example: <a href="http://codepen.io/anon/pen/LkzBQJ" rel="nofollow noreferrer">http://codepen.io/anon/pen/LkzBQJ</a></p>
  
  <p>html:</p>
  
  <pre><code>&lt;h1&gt;
    &lt;span class="title-text"&gt;
      This is some text
    &lt;/span&gt;&lt;span class="badge"&gt;yo!&lt;/span&gt;
  &lt;/h1&gt;
  &lt;h1&gt;
    &lt;span class="title-text"&gt;
      This is some broken text
    &lt;/span&gt;&lt;span class="badge"&gt;yo!&lt;/span&gt;
  &lt;/h1&gt;
  </code></pre>
  
  <p>css:</p>
  
  <pre><code>h1 {
    width: 350px;
  }
  
  .badge {
    color: #f6511d;
    display: inline-block;
    border: 1px solid #f6511d;
    border-radius: 3px;
    font-size: 0.8em;
    padding: 0.1em 0.2em;
    line-height: 0.97em;
    margin-left: 0.4em;
    vertical-align: 1px;
  }
  </code></pre>
  
  <p><strong>UPDATE2:</strong> In my particular case, both the text in the first element, and the badge have to be rendered dynamically, using JavaScript. So Ricardo’s solution below (wrap the last word of the text and the badge in a span with <code>white-space: nowrap</code>), although working, will not be very easy to implement.</p>