Automatically remove orphans from paragraph text blocks – CSS

Posted on

In this post, I describe how to use CSS to automatically remove orphans from the end of paragraphs or text blocks.

An orphan is a single word that sits on its own at the bottom of a paragraph and should be avoided if possible.

 

Resolution

To automatically remove orphans using CSS, use the text-wrap property with the value pretty, e.g.

p {
text-wrap: pretty;
}

Orphans are now automatically removed:

This paragraph of text is long enough to wrap onto two lines and the last word is no orphan.

Leave a Reply

Your email address will not be published. Required fields are marked *