One way to do this is with JavaScript implementations of the LaTeX hyphenation/justification algorithm. Check out [1] and [2] for examples.
[0]: https://i.imgur.com/65ICUVW.png
One way to do this is with JavaScript implementations of the LaTeX hyphenation/justification algorithm. Check out [1] and [2] for examples.
[0]: https://i.imgur.com/65ICUVW.png
There's even a plausible theory that justified text is bad for readability (perhaps because the brain loses that hint of which line is which). I haven't seen a lot of studies[1] replicating it, but I don't see any studies taking the other side. There's also the problem that it alters the inter-word spacing, which might also reduce readability since the brain can't rely on consistent word spacing.
I sympathize if you're conditioned to be annoyed every time you see an unjustified right column, but that's not a reason to recommend justified text.
Publishers (and authors, when they're considering text style details) need to understand that ebook publishing isn't the same as publishing print books. For print, decisions about font and styling have to be made, because otherwise there's no text.
For an ebook, unless it's a picture book or textbook with careful design[2] or some other kind of book where layout is the primary concern and readability is secondary, no features of the main style of text should be hardcoded. It needs to be left up to the ebook reader, and whatever defaults plus user customization it has.
[1] e.g. https://doi.org/10.1111/j.1467-8535.1986.tb00491.x
[2] These kinds of books, where publisher-dictated styling makes sense, shouldn't even be published as epubs; it often ends up as a disaster no matter how hard they try. They should publish the books as pdfs only.
It is OK, we all configure our readers to our taste.
text-align: justify;
text-justify: inter-word;
you should get what you're looking for. At least it worked in Firefox inspector.Anyway, in all current browsers, `text-align: justify` does greedy text layout, where it fits as many words in each line as it can before wrapping. This is technically trivial, but visually inferior to Knuth-Plass line breaking, which tries to find the most visually-pleasing place to break lines. Look at the screenshots of https://github.com/robertknight/tex-linebreak to see the difference. It can be rather stark.
[1] https://mpetroff.net/files/pre-calculated-line-breaks-demo/
With modern 4k screens in very small displays the old argument of "computers don't have enough resolution to show justified text properly" becomes absurdly outdated.
We now have the technology to have nice justified text everywhere. Please use it.
Right aligned jagged text looks ugly.
Another is just to use CSS (text-align: justify).
Why use JS for this?