W3C home > Mailing lists > Public > www-style@w3.org > June 2015

[css-text][css-conditional] language specific support for hyphenation and justification

From: Florian Rivoal <florian@rivoal.net>
Date: Tue, 16 Jun 2015 14:24:01 +0200
Message-Id: <4B76D312-8D75-4291-9CA1-F4CB37DC66EB@rivoal.net>
To: www-style list <www-style@w3.org>, www International <www-international@w3.org>
Many people (here's one example[1]) recommend that justification should only be used if you can also do hyphenation, as otherwise it looks bad.

To do that in a browser, you may be tempted to write this:

  p { text-align: left; }
  @supports (hyphens: auto) {
    p {
      hyphens: auto;
      text-align: justify;

However, it doesn't quite do cut it.

* Problem 1

Support for hyphenation is language dependent. Even if a browser properly implements the 'hyphens' property, it may not have a dictionary to do it for the language at hand.

* Problem 2
"justification should only be done if you can also do hyphenation" is only true in some languages. For example, Japanese does not use hyphenation to do justification (See [2] for how it's done instead), and languages using the Arabic script can do pretty justification using kashida[3].

Problem 1 would be addressed if we added something like
  @supports hyphenation-language(fr) {...}
but it seems awfully specific and narrow.

Problem 2 can be handled by authors using :lang() selectors, so it is less of an issue. However, for stylesheets meant to be used over an open ended set of languages, being exhaustive is really tedious, and authors are unlikely to have the linguistic knowledge to do this properly.

We could generalize a little bit, and go with something like (to be bikesheded):
  @supports nice-justification(fr) {...}
where the condition evaluates to true if one of the following is true:
- The language should use hyphenation and the browser has the necessary resources to do it
- The language should use some other approach (kashida, etc) and the browser knows how to do at least one of the acceptable techniques
- The language is known not to need any language-specific algorithm or resource to justify well

This is broader than @supports hyphenation-language(), but not by a whole lot, and it deciding which languages need what may be quite controversial, so I am not sure that's a great idea either.

Any idea on how to solve this well?

 - Florian

[1] http://practicaltypography.com/justified-text.html
[2] http://www.w3.org/TR/jlreq/
[3] https://en.wikipedia.org/wiki/Kashida
Received on Tuesday, 16 June 2015 12:24:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:54 UTC