or
https://bugs.webkit.org/show_bug.cgi?id=332074
Steps to reproduce
Actual results
Case 1 (inline-size: 16em): with auto, every line is full, including the last one (8 lines of 17 characters). With pretty, every line is shorter and there is one more line (9 lines of 15 or 16 characters), leaving space at the end of every line.
Case 2 (inline-size: 28em): with auto, the lines are 30, 30, 30, 30 and 16 characters. With pretty, they are 27, 27, 27, 27 and 28 characters, exactly the same as balance.
The same happens without lang="ja". I also compared widths from 10em to 30em: pretty makes every line of the Japanese paragraph shorter than auto at every width. At 10em it turns 14 lines into 17 lines, more than balance (14 lines). English text shows the same tendency (at many widths pretty breaks exactly like balance, and at 10em 12 lines become 15), but it is much more visible in Japanese, where auto already fills every line to the end edge.
Expected results
The "Test (pretty)" box should look like the "Reference (auto)" box, apart from a few characters moved to the last line to avoid a short last line.
Japanese text can break between almost any two characters, so auto already gives lines of equal length. Japanese typography sets lines to the full line length (see Requirements for Japanese Text Layout, https://www.w3.org/TR/jlreq/). Shortening every line and adding lines makes the layout worse, not better.
Specification
CSS Text Module Level 4, 5.4 Selecting How to Wrap: the text-wrap-style property: https://drafts.csswg.org/css-text-4/#text-wrap-style
pretty asks the UA to bias for better layout over speed. It may avoid short last lines and may improve the layout in other ways, such as reducing variation in line length. The details are up to the UA, so pretty breaking like balance is not forbidden by itself. In Japanese text, however, auto already has no variation in line length except on the last line, so making the lines shorter does not improve the layout.
This looks related to bug 288650 ("[text-wrap-style:pretty] Bias ideal line width to be closer to max bounds"), whose draft PR (https://github.com/WebKit/WebKit/pull/41458) moves the ideal line width of pretty closer to the available width. I am filing this separately because 288650 has no description and does not mention CJK text or the increase in the number of lines.
Environment
No settings changed.
Other browsers
Web Platform Tests
There are no tests for where pretty breaks lines. The existing tests check only parsing and crashes:
Results from wpt.fyi on 2026-11-18 (master runs of 2026-11-16).
Created attachment 482413 [details] Testcase
Two corrections to the description.
In "Actual results" I wrote that pretty makes every line of the Japanese paragraph shorter than auto at every width. That is not accurate for the last line. In case 2 of the testcase (inline-size: 28em), the last line gets longer: auto gives lines of 30, 30, 30, 30 and 16 characters, and pretty gives 27, 27, 27, 27 and 28. What pretty shortens is every line except the last one. Case 1 (16em) is different only because auto already fills the last line there, so the last line gets shorter too.
pretty
auto
In "Specification" I paraphrased pretty as "may improve the layout in other ways". The spec is stronger than that: besides possibly avoiding short last lines, the UA "should also improve the layout in additional ways", and pretty is otherwise equivalent to auto. Shortening every full line of Japanese text and adding lines does not improve the layout in this sense.
https://drafts.csswg.org/css-text-4/#text-wrap-style
Takahiro, thank you for the detailed report and test cases!
The issues you are seeing can be traced to two separate problems with how pretty scores line breaks.
This is tracked in https://bugs.webkit.org/show_bug.cgi?id=332333
This is tracked in https://bugs.webkit.org/show_bug.cgi?id=332332
I'll keep this bug open until both have landed.
Thank you for looking into this so quickly, and for the clear explanation of the two causes. Splitting them into bug 332333 (target width and penalizing only short lines) and bug 332332 (scoring the last line only when it is an orphan) makes sense to me, since they match the two cases in the test case.
I'm happy to test the fixes against the test case once they land in Safari Technology Preview.