

It creates a back-reference to the non-white-space that you can use in the replace text. The regex simply finds all instances (using the g flag) of a whitespace character ( \S) followed by any number of non-whitespace characters ( \s) followed by a period. Var div = document.getElementById("articleText") ĭiv.innerHTML = (/\S(\s*)\./g, " $1.") You can create this javascript and put it at the end of your page: This is some text with one word on its own line at the end. Loosening or tightening the spacing on one line or one word can be enough to force a change. But He wanted to know what I was ‘doing’ for the widows and orphans. My whole life revolved around God and His Word. I was training up future leaders in my church. I organized Bible studies for others to feast on His Word. I taught His Word in Sunday School at church. Apply changes globally throughout the document or only in certain areas. I was studying God’s Word in seminary classes. Use tracking and kerning to change line endings. You always want to replace the whitespace before the last word with Īssuming you have this html (which is styled to break right before "end" in my browser.monkey with the width if needed): Manually hyphenating some lines eliminates some widows and orphans without changing entire sections of a document.If you want to handle it yourself, without jQuery, you can write a javascript snippet to replace the text, if you're willing to make a couple assumptions: It's less code, and supported everywhere.ĮDIT: - I've discovered that the Outlook App (iOS and Android) doesn't support the entity, so I've had to combine both solutions: e.g.:

Read more about about the white-space property on this link: ĮDIT: - Since this isn't supported in Outlook, I've been adding a non-breaking space between the last two words in a sentence. In a fluid/responsive layout, if you do it right, the last few words will break to a second line until there is room for those words to appear on one line.

So what I do is surround the last two or three words (or wherever I want the "break" to be) in a span, add an inline CSS (remember, I deal with email, make a class as needed): I know you wanted a javascript solution, but in case someone found this page a solution but for emails (where Javascript isn't an option), I decided to post my solution.
CHANGE WIDOWS AND ORPHANS IN WORD 2010 PROFESSIONAL
Many professional page layout applications, such as Adobe InDesign, can automate the removal of orphans by automatically adding non-breaking spaces where orphans occur is there any sort of equivalent solution for HTML? Incidentally, the CSS2.1 properties orphans (and widows) 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).
CHANGE WIDOWS AND ORPHANS IN WORD 2010 MANUAL
While I know that I could manually correct this by placing an HTML non-breaking space ( ) 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. Instead, it would be preferable to have the paragraph break as follows: "This paragraph no longer ends with an undesirable For example: "This paragraph ends with an undesirable orphaned I was wondering if there's a way to automatically control orphaned words in an HTML file, possibly by using CSS and/or Javascript (or something else, if anyone has an alternative suggestion).īy 'orphaned words', I mean singular words that appear on a new line at the end of a paragraph.
