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

I'm not sure ideas like `hyphens: nowrap` will entirely solve the use-cases here. People want to prevent a break after the (explicit) hyphens in words like "T-shirt", "A-frame", or "e-visa", but I suspect they often wouldn't want to prevent breaking after a hyphen in longer compounds such as "helter-skelter", "state-of-the-art", or "middle-of-the-road".

So to apply the behavior only to certain words such as "T-shirt", while allowing other hyphens to break, the author would need to wrap the relevant word in a `<span>` styled with `hyphens: nowrap`; but at that point, they could just as well have used `text-wrap: nowrap`. And the point here is to avoid requiring extra markup around the individual words.

(If an author does want to prevent breaks after *all* explicit hyphens, `hyphens: nowrap` would be fine, and I'm not against introducing such a value; but I don't think it entirely addresses the issue.)

The "right" solution for the "T-shirt" case, IMO, would be to use U+2011 NON-BREAKING HYPHEN in such words, but (as has been noted) this may not always be practicable. It seems like a solution involving `hyphenate-limit-chars` (or similar), but applying to explicit hyphens as well as automatically inserted ones, might be the most useful.

(Another thing that might help would be for browsers to improve their rendering of U+2011: if it is not supported by the current font, they could perhaps fall back to rendering U+2010 or even U+002D, rather than switching to a fallback font that might look quite out of place. This would make it more feasible to use the "correct" Unicode solution of directly encoding the hyphen as non-breaking.)


-- 
GitHub Notification of comment by jfkthame
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3434#issuecomment-2449671921 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 31 October 2024 11:55:09 UTC