Copied!
It's on your clipboard.
You’ve been offline for 0 second. Please check your Internet connection.

Help Us Improve

Found an issue or have an idea? Let us know.
Select all that apply...
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Prevent Orphan Words in Headlines and Text
Preview
Overview

This snippet prevents a single orphan word from wrapping onto a new line in your headlines or body text. It does this by replacing the last space with a non-breaking space, keeping the last two words together for cleaner typography.

Documentation
Code Setup
Walkthrough

Copy To Elementor
Option A: Balance Wrapping For All Text Elements

Add this code with a snippets plugin in <head>, or place it in Page CSS block or Site Settings.

Language
Copy
* {
  text-wrap: balance;
}
Option B: Balance Wrapping For Headings & Paragraphs

Add this code with a snippets plugin in <head>, or place it in Page CSS block or Site Settings.

Language
Copy
h1, h2, h3, h4, h5, h6, p {
  text-wrap: balance;
}
Option C: Avoid Orphan with Custom Class

Add this code with a snippets plugin in <head>, or place it in Element CSS, Page CSS, or Site Settings. Use the .ou-avoid-orphan custom class on any element where you want balanced text wrapping.

Language
Copy
.ou-avoid-orphan {
  text-wrap: balance;
}
Option D: Avoid Orphan with Selector Tag in Elementor

Add this code inside the Custom CSS field of an element in Elementor. The selector tag automatically targets only that specific element, so the style won’t affect others.

Language
Copy
selector {
  text-wrap: balance;
}

Language
Copy

Language
Copy
Publish and preview live

Some solutions only work on the live site. Always publish and test after each change, as results may not appear in the editor.

Absolutely Codefree
If you were expecting some fancy snippet, sorry. This one runs just fine on its own.
C’mon, You Got This
Do we really need to spell this one out? It’s as straightforward as it gets.
Resorce Details
Collection
Basics
Category
Category
Styling
Interaction
Builder
Last Updated
September 16, 2025