Skip to content

[css-text] Prevent line breaking after explicit hyphens #3434

Open
@hftf

Description

@hftf

I want to prevent hyphenation/line breaking of words containing hyphens (hyphenated compounds). Some common examples of hyphenated compounds in English are , , and .

Why?

This behavior is important for documents that prioritize legibility over aesthetics, such as:

  • highly technical documents¹
  • documents that will primarily be read out loud
  • pedagogical documents

These documents may want to apply the behavior to the entire document, not on a case-by-case basis.

¹ This very spec once faced a similar issue in which unwanted hyphenation led to confusion: #2307

Current status

CSS Text Module Level 3 does not define what hyphenation opportunities are:

Hyphenation occurs when the line breaks at a valid hyphenation opportunity…. CSS Text Level 3 does not define the exact rules for hyphenation….

Under hyphens, it says:

none
Words are not hyphenated, even if characters inside the word explicitly define hyphenation opportunities.

However, hyphens: none does not give the expected result in most browsers.
For example, see how Chrome 70/Mac renders this JSFiddle:

I am concerned that the current spec gives authors very little control over a simple display requirement. For example, it never mentions the behavior of U+002D HYPHEN-MINUS, the most widespread hyphen character by far, even once.

Some workarounds

Wrap all hyphenated compounds in <span style="white-space:nowrap;"> or <nobr> (nonstandard).

Cons:

  • Adds lots of unnecessary, presentational markup

Surround all hyphens with U+2060 WORD JOINER.

Cons:

  • Affects searching and copying

Replace all hyphens with U+2011 NON-BREAKING HYPHEN.

Cons:

  • Affects searching and copying
  • Affects display; may look very ugly depending on the font (or fallback font)
    • Few fonts have a glyph for U+2011 (379 out of 3426 on my system do).
      Even if they do, U+2011 may not look identical to U+002D or U+2010.

The Unicode Line Breaking Algorithm (UAX 14) recommends this method, but it seems rare in practice:

2011 NON-BREAKING HYPHEN
This is the preferred character to use where words need to be hyphenated but may not be broken at the hyphen. Because of its use as a substitute for ordinary hyphen, the appearance of this character should match that of U+2010 HYPHEN.

Possible solutions

  1. Define “hyphenation opportunities”
  2. Re(de)fine hyphens: none
  3. Add a brand new value, such as hyphens: none-including-hyphens

Questions

  1. Does this affect CSS Text Module Level 3 or Level 4, or neither?
  2. Will it impact the Last Call?

I can’t find any previous discussion on this topic; sorry if it’s a duplicate.

Thank you for considering this feedback – it’s my first time engaging with the standards process.

Further reading

Metadata

Metadata

Assignees

No one assigned

    Labels

    Tracked in DoCcss-text-4i18n-trackerGroup bringing to attention of Internationalization, or tracked by i18n but not needing response.

    Type

    No type

    Projects

    Status

    Not for TPAC?

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions