title: Is there a way to automatically control orphaned words in an HTML document?
body: <p>I was wondering if there's a way to <strong>automatically control orphaned words</strong> in an HTML file, possibly by using CSS and/or Javascript (or something else, if anyone has an alternative suggestion).  </p>
  
  <p>By 'orphaned words', I mean singular words that appear on a new line at the end of a paragraph.  For example:</p>
  
  <pre>"This paragraph ends with an undesirable orphaned
  word."</pre>
  
  <p>Instead, it would be preferable to have the paragraph break as follows:</p>
  
  <pre>"This paragraph no longer ends with an undesirable
  orphaned word."</pre>
  
  <p>While I know that I could manually correct this by placing an HTML non-breaking space (<code>&amp;nbsp;</code>) between the final two words, I'm wondering if there's a way to automate the process, since manual adjustments like this can quickly become tedious for large blocks of text across multiple files.</p>
  
  <p>Incidentally, the CSS2.1 properties <code>orphans</code> (and <code>widows</code>) only apply to entire lines of text, and even then only for the printing of HTML pages (not to mention the fact that these properties are largely unsupported by most major browsers).</p>
  
  <p>Many professional page layout applications, such as Adobe InDesign, can <a href="http://vector.tutsplus.com/tutorials/designing/quick-tip-automatic-formatting-using-grep-styles-in-adobe-indesign/" rel="noreferrer">automate the removal of orphans</a> by automatically adding non-breaking spaces where orphans occur;  is there any sort of equivalent solution for HTML?</p>