brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: text-wrap: pretty in css avoids a lonely last word in a paragraph

Css
~/tips/tip-css-text-wrap-pretty-orphans

article p { text-wrap: pretty; }

Asks the browser to break paragraph lines so the final line does not hold a single orphan word.

Balanced headings are one thing, but body text can also end on a single word.

article p { text-wrap: pretty; }

text-wrap: pretty asks the browser to use a slower line breaking algorithm so the last line of a paragraph is not a single short word. MDN says it costs some performance, so use it on longer blocks of body text, whereas balance is meant for short headings and only works up to a limited number of lines. Chrome and Edge support pretty since version 117 and Safari since 26. At the time of writing Firefox does not, and browsers that do not know the value ignore it, which makes it a harmless enhancement. The result can change the line count of a paragraph slightly.

Further reading: MDN: text-wrap-style

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link