W3C home > Mailing lists > Public > public-css-archive@w3.org > July 2018

Re: [csswg-drafts] [css-text] A single leading white-space should prevent word breaking honoring white-space: pre-wrap

From: Florian Rivoal via GitHub <sysbot+gh@w3.org>
Date: Fri, 20 Jul 2018 15:28:45 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-406635802-1532100524-sysbot+gh@w3.org>
Commenting late, sorry.

I believe that:

* All browsers are correct in cases 1.1, 1.2, and 2.2

* Chrome is wrong in 2.1, other browsers are correct: a soft wrap opportunity exists at the end of the white space sequence, and word-wrap only allows breaking in the middle of words when there isn't one.

* 3.1 / 3.2 The spec doesn't say, as word-break: break-word is not a combo that exists according to the spec. If you do want to implement it, the safari behavior makes more sense to me to keep the parallel with word-wrap:break-word, but whatever.

* 4.1: I think all browsers are correct. word-break:break-all introduces a wrap opportunity between letters, so breaking in the middle of the word is allowed, but the spec says nothing about the priority of break-points (except those created by word-wrap, which come last), so browsers can chose whether to break after the space or in the middle of the word, as long as that does not lead to overflow (which it doesn't, in this case). Whether the behavior of Safari is preferred or not is up to you, but not decided by the specification. My personal expectation / preference is not what Safari does, but it is allowed.

* 4.2: Chrome is wrong, and other browsers are correct. There is a soft wrap opportunity the end of the white space sequence, so overflowing is not allowed.


> My understanding is that among the same-priority wrap opportunities the last opportunity that still prevents overflow should be preferred. 

That is one possibility, and it is expected to be what most browsers will do, but it is not strictly required.
If browsers want to break at one of the other allowed point in order to make the text prettier (for example, avoid [rivers](https://en.wikipedia.org/wiki/River_(typography)), or better balance the length of lines, or any other consideration), it is allowed.


----

In conclusion, the Chrome behavior is a spec violation, and both the solutions proposed in  https://github.com/w3c/csswg-drafts/issues/2907#issue-340229290 and in https://github.com/w3c/csswg-drafts/issues/2907#issuecomment-404944849 are valid per spec.

The second one (like Firefox/Edge) is the one that is mostly expected since that is the result of the simple greedy algorithm, but if a browser thinks that the first one (like Safari) is better typography, it is allowed too.

If you have no strong opinion on the quality of the typography, I suggest aligning on Firefox/Edge, based on simplicity (no priority, greedy line breaking).

-- 
GitHub Notification of comment by frivoal
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2907#issuecomment-406635802 using your GitHub account
Received on Friday, 20 July 2018 15:28:47 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 9 October 2019 08:16:46 UTC