logoalt Hacker News

Justifying Text-Wrap: Pretty

77 pointsby surprisetalklast Thursday at 6:29 PM28 commentsview on HN

Comments

albert_etoday at 2:51 AM

Are hypens no longer acceptable?

There is no mention of it in the post. If words (in any language) can be arbitrarily long and columns can be arbitrarily narrow, we will need to solve for this anyway.

Even without those extremes, I feel that there will always be place for the good old hypen when displaying or printing text for the main purpose of readability. No need to max out on perfect "look" in every application of text.

In fact in many places one might even find columns with jagged right edges more readable -- letting you visually distinguish each line from the one above/below it easily by length alone -- and may even lend a certain aesthetic character that is the opposite of mechanical / boring / machine produced / sterile.

Of course not negating the need for a well implemented method without bugs to justify text correctly when the use case demands it.

show 2 replies
_nivlac_today at 5:10 AM

The example for "avoid short last lines" has a short last line - if that was intentional, a great touch by the writer!

show 1 reply
iguessthislldotoday at 5:07 AM

The Webkit blog post talks about this, didn't know it had a name:

https://en.wikipedia.org/wiki/River_(typography)

sbinneetoday at 4:19 AM

It reminds me of one of my favorite programs, par[1].

[1]: http://www.nicemice.net/par/

notpushkintoday at 3:01 AM

I’m looking at the comparison [0] and the `pretty` example is hyphenated, while greedy is not. Not sure it’s fair to compare them like that, considering we’ve had `hyphens: auto` for a while now.

Edit: it’s actually vice versa! Which I should have known because the very next paragraph says:

> But the “smart” algorithm decides to add an entire line to it, which requires inflating all the white space proportionally.

Which is exactly how the example on the right looks.

[0]: https://matklad.github.io/2026/02/14/justifying-text-wrap-pr...

show 1 reply
nayrocladetoday at 3:15 AM

> Inexplicably, until 2025, browsers stuck with the naive greedy algorithm, subjecting generations of web users to ugly typography.

> WebKit devs, you are awesome for shipping this feature ahead of everyone else...

Um, no? Chrome shipped this feature in 2023: https://developer.chrome.com/blog/css-text-wrap-pretty

Safari isn't early shipping this, they're late. Though not as late as Firefox, admittedly.

show 2 replies
evikstoday at 3:08 AM

> We are getting closer and closer to the cutting-edge XV-century technology. Beautiful paragraphs!

While the broader point is fine, the example to me is just bad to me: very narrow column with a lot of hyphens and identical width/no variety making it harder to anchor your eye (though colored letters are awesome and play this role)

Ok, bad rag is bad, but the ancient text goes overboard in the other direction. This looks close to the form-over-function vibe.

show 2 replies