Text Orphans
Applying the data-orphans attribute will wrap prevent the last two words from breaking to a new line.
A red border is shown around the <span class="u-nowrap"> elements below to make it easy to visualize what’s happening. With JavaScipt disabled, all lines have a single word orphan.
Defaults to wrapping last 2 words:
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
Inline SVGs count as words:
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
Can define custom word count using data-orphans="3":
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth.
The script will never break child elements, so these examples will do nothing.
- First second third fourth fifth sixth.
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>
- First second third fourth fifth sixth. <%= svg "icons/globe", width: 16 %>