Skip to content

[css-text-4] Add an optional second value to hyphenate-character to render the unchosen ­ #12255

Open
@jfrech

Description

@jfrech

Status quo

Currently, hyphenate-character's values are defined as (cf. https://www.w3.org/TR/css-text-4/#hyphenate-character [2025-05-31])

hyphenate-character = auto | <string>

with the semantics that when a &shy; word-break opportunity is taken, the &shy; character is rendered as the given string (which has an auto default). When a &shy; word-break opportunity isn't taken, the &shy; character isn't rendered.

Proposal

I propose adding a second, optional argument to hyphenate-character with default value "" that specifies the rendering of a &shy; character whose word-break opportunity isn't taken:

hyphenate-character = auto | <string> | <string> <string>

Motivation

Hyphenation rules in modern English (e.g. en-GB) and German after the spelling reform (e.g. de-DE) fit hyphenate-character's model well: when you can break, break and add a hyphen, else don't break and leave the word alone.

However, when typesetting German preceding the spelling reform (language code de-DE-1901), hyphenation may add and remove letters:

((de-DE-1901))

Nach Tagen der Suche konnte sie eine Pampelmuse entdecken, und begann, ein Stilleben anzufertigen.
                                                     ^^ "ck" -> "k-k"         ^^ "ll" -> "ll-l"
    
Nach Tagen der Suche konnte
sie eine Pampelmuse entdek-
ken, und begann, ein Still-
leben anzufertigen.

Adding letters "ll" -> "ll-l" when breaking can be achieved with contemporary CSS:

<p lang="de-DE-1901">Nach Tagen der Suche konnte sie eine Pampelmuse entdecken, und begann, ein
<span style="hyphenate-character: 'l-';">Stil&shy;le</span>&shy;ben
anzufertigen.</p>

But changing letters "ck" -> "k-k" when breaking, to my knowledge, cannot be achieved in pure CSS (I have written an ECMAScript resize observer which changes letters' display: none styling, though it possibly falls into a never-ending loop when the font rendering gives different characters too dissimilar widths).
With an unused-&shy; text parameter to hyphenate-character, the break opportunity could be aptly described:

<p lang="de-DE-1901">Nach Tagen der Suche konnte sie eine Pampelmuse
ent&shy;<span style="hyphenate-character: 'k-' 'c';">de<span
  style="font-size: 0px; float: inline-end;">c</span>&shy;ken</span>,
und begann, ein Stilleben anzufertigen.</p>

Raison d'être

I think adding an as-described non-taken &shy; rendering argument to hyphenate-character opens up the possibility for correctly breaking justified de-DE-1901 text, a feature CSS is currently lacking, through a generic feature without introducing de-DE-1901-specific styling rules.

Pre-orthography-reform German has its place on the Web: when citing older texts in a justified layout, incorrectly breaking invalidates the citation and not breaking aesthetically hurts the text. Furthermore, active publications exist that choose to write in de-DE-1901 (e.g. Lettre International (cf. https://www.lettre.de/ [2025-05-31]).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions