Open valtlai opened 5 years ago
I have this problem all the time with -prefixed-css-properties
! But I would consider it a browser bug. The browsers have a lot discretion in determining line-breaking positions. But whoever wrote that code in certain browsers clearly didn't consider this case.
The only reason to add CSS control would be if there was a situation where you would want the line to leave an initial hyphen hanging on its own.
Related to the discussion in https://github.com/w3c/csswg-drafts/issues/3434#issuecomment-448726726
https://www.w3.org/TR/css-text-3/#line-break-details
UAs that allow wrapping at punctuation other than spaces should prioritize breakpoints. (For example, if breaks after slashes are given a lower priority than spaces, the sequence "check /etc" will never break between the "/" and the "e".) As long as care is taken to avoid such awkward breaks, allowing breaks at appropriate punctuation other than spaces is recommended, as it results in more even-looking margins, particularly in narrow measures. The UA may use the width of the containing block, the text’s language, and other factors in assigning priorities: CSS does not define prioritization of line breaking opportunities.
Agree with @AmeliaBR that this is a quality-of-implementation issue. I think the spec clearly expects the behavior you're expecting; but we could maybe benefit from a testcase.
Committed https://github.com/w3c/csswg-drafts/commit/4789b41c2b2dec71f9dac8cc08f5c2eb98860b2a to clarify that
word-break: break-all
line-break
in list of factors suggested for consideration of prioritization rulesline-break: anywhere
is specified (This is clearly specified under the definition of anywhere
, but it seemed useful to point out here as well.)I think that should help with drawing up tests here. Marking Agenda+ for review as we are in Last Call. Otherwise I think this issue is closed, spec-wise.
The CSS Working Group just discussed Prevent line break after hyphen preceded by space
, and agreed to the following:
RESOLVED: accept these changes for text L3
Chromium issue: https://crbug.com/974470
Chromium issue: https://crbug.com/974470
This is marked as WontFix. Is this an issue with Unicode?
@valtlai Maybe but not necessarily. Chrome can fix this if they want to, with the specs as they are today. The specs aren't precise enough to require that behavior, but they allow it, and this kind of refinement is expected from good quality implementations. If Chrome wants to fix this case only if the Unicode spec requires them to, then asking Unicode to change is a possible path forward. Convincing Chrome that they should change with the specs as they are is another one. No strong opinion as to which is more likely to be successful.
I want to prevent a line break after a hyphen that is preceded by a space.
So a string like
can be broken as
but not
I’m not sure if this can be solved by CSS spec (e.g., a new keyword for
hyphens
oroverflow-wrap
, etc.) or if it’s a browser bug: Firefox does like described by default, Chrome doesn’t.(Demo: https://codepen.io/valtlai/pen/WLRjeo/left/?editors=1100)
Another example
String: ``` foo -webkit-baz ``` Allowed: ``` foo -webkit- baz ``` Disallowed: ``` foo - webkit-baz ```