Skip to content

[css-text] Should 'hyphens: auto' work if lang="" is not declared? #869

@zcorpan

Description

@zcorpan

https://drafts.csswg.org/css-text-3/#hyphens-property

See
https://bugs.webkit.org/show_bug.cgi?id=166485
https://bugs.chromium.org/p/chromium/issues/detail?id=676270

WebKit and Chromium hyphenate text with 'hyphens: auto' when no language is declared. Gecko does not.

MDN says:

Hyphenation rules are language-specific. In HTML, the language is determined by the lang attribute, and browsers will hyphenate only if this attribute is present and if an appropriate hyphenation dictionary is available.

Spec says:

Correct automatic hyphenation requires a hyphenation resource appropriate to the language of the text being broken. The UA is therefore only required to automatically hyphenate text for which the content language is known and for which it has an appropriate hyphenation resource.

Authors should correctly tag their content’s language (e.g. using the HTML lang attribute) in order to obtain correct automatic hyphenation. UAs may refuse to automatically hyphenate untagged content regardless of the hyphens property value.

https://drafts.csswg.org/css-text-3/#valdef-hyphens-auto

Now the spec doesn't forbid it, but I think the intent is that UAs should not hyphenate untagged content. (Correct?)

Test case/demo:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4761

<!DOCTYPE html>
<style> div { border:solid; width:150px; -webkit-hyphens:auto; hyphens:auto; } </style>
No lang
<div>Long words like implementation, initialization, realization, and hyphenation.</div>
lang=en-US
<div lang=en-US>Long words like implementation, initialization, realization, and hyphenation.</div>

In the WebKit bug there is resistance to changing their behavior to that of Gecko.

I think it would be good to figure out what behavior we ideally want browsers to have when the language is not declared, and put that in the spec so we can achieve interoperable behavior for this case.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions