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

Re: [csswg-drafts] [css-text] Prevent line breaking after explicit hyphens (#3434)

From: Florian Rivoal via GitHub <sysbot+gh@w3.org>
Date: Wed, 19 Dec 2018 20:05:54 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-448726726-1545249953-sysbot+gh@w3.org>
So, based on the teleconf discussion minuted above, we've agreed that the behavior currently observed in browsers (`hyphens:none` does not suppress wrapping after U+002D or U+2010) was what the spec intended, and I just clarified that in https://github.com/w3c/csswg-drafts/commit/806cd4e5fa53507d14f8860cf41aa438d2b07e93

Now, as to whether we should have a separate control for this in level 4, everybody agreed that this was a useful thing to do in certain occasions, and we looked at different scenarios:

* using a U+2011 NON-BREAKING HYPHEN can be appropriate for things that shouldn't break for semantic reasons, and should survive copy&paste. (Also, the UA should be smart about search).
* using wrapping element styled with `white-space:nowrap` is appropriate when there's a semantic justification for having a wrapping element
* For words like e-mail or T-shirt, the UA is already allowed to be smart enough and decide that hyphens after a single letter do not introduce a breaking opportunity, or some similar heuristic.

The remaining question is whether there are case where you want to suppress wrapping at hyphenation that don't fall in any of these.

I think the answer is yes. Doing `<code style="white-space:nowrap">grid-template-rows</code>` works fine to suppress the wrapping opportunity in that single word, but `<code style="white-space:nowrap">grid-template-rows: 1fr min-content 2fr</code>` would also suppress wrapping at  spaces, which isn't necessarily desired, and there's no particular justification for having wrapper elements around each token in a code sample. Similarly, code samples are often styled with `white-space: pre-wrap`, and short of adding wrapper elements around every token, we cannot prevent wraps after hyphens.

Another example could be turning off wrapping after hyphens on people's names, to make sure there's no confusion about whether the hyphen is part of the name or inserted at layout time. But names can also contain spaces, and we don't want to suppress that wrapping opportunity.

Any other situation where the semantic of the phrase/paragraph/block (any piece of text that might contain spaces as well), rather than the semantic of the individual word calls for turning off wrapping after hyphens cannot be addressed without adding an explicit control. So I think we should have it.

Bikeshedding time? `hyphens: nowrap` ?


-- 
GitHub Notification of comment by frivoal
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3434#issuecomment-448726726 using your GitHub account
Received on Wednesday, 19 December 2018 20:05:56 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:41 UTC