You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[selectors-4] :lang example needs refinement #13644
Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.i18n-needs-resolutionIssue the Internationalization Group has raised and looks for a response on.selectors-4Current Work
| E:lang(zh, "*-hant") | an element of type E tagged as being either in Chinese (any dialect or writing system) or otherwise written with traditional Chinese characters | § 7.2 The Language Pseudo-class: :lang() | 2/4 |
This example uses the ranges zh and *-hant. Tagging Chinese languages is more complex than most other languages. The purpose of this illustration is to show the :lang selector as an example. It would probably be better to use an example that doesn't involve this complexity.
Perhaps use a combination such as en and *-CA instead:
an element of type E tagged with a language tag for English (en) or any language tag with the region Canada (*-CA)
I think this is the early/simple example, with the meat of :lang described later providing more extensive examples. Originally when I wrote this comment I did use Serbian+Cyrillic, but replaced it in the final comment. My thinking was: the use case for wanting to select "Serbian or anything written in Cyrillic" is pretty marginal (zh + *-hant is actually a more likely example, since several Sinitic languages can be written in Traditional Chinese). Since the goal is only to illustrate :lang at a high level, I thought maybe en/*-CA might serve well enough.
This is fairly editorial and probably we should tag it as such.
I think Serbian or Cyrillic is a more realistic example than English or whatever from Canada. Not all, but most language based selection in CSS has something to do with typography, and that is much more closely correlated with script than with geography. That said, script is very often left out of language tags included in the markup, so there may not be much to select, since we don't do the kind of normalization that would fill in the blanks in that area.
since we don't do the kind of normalization that would fill in the blanks in that area
That's also a potential gap. Elsewhere (CLDR, JS, etc.) the use of algorithms to improve matching and fallback is helpful and maybe we should discuss their use in the HTML/CSS space? This issue wouldn't be the place for that discussion, obviously. I'll consider another issue on the side for that.
Not all, but most language based selection in CSS has something to do with typography
Well... it depends on what one is trying to do. What makes the example funky is that selector authors are likely to do language or script or region, rather than mixing a language, a script, and a region in a single selector. We contrive the example to show that the :lang() feature can do more than just a single, simple primary language tag.
I can see some people being upset that the example implies en and fr-CA would be treated the same.
It doesn't imply that: it outright means that! 😉 Not only fr-CA, but iu-CA and zh-CA and many more.
An alternative to trying to find a "realistic" example of a primary-language-only + a wildcarded range with no primary would be to use more clearly unrealistic examples, like E:lang(tlh, "*-Cyrl", "*-AQ") (Klingon, anything Cyrillic, anything Antarctica).
I think Serbian or Cyrillic is a more realistic example than English or whatever from Canada. Not all, but most language based selection in CSS has something to do with typography, and that is much more closely correlated with script than with geography.
I mostly agree. Region-based presentation variations will mostly be divorced from the primary language. But then, so will script-based ones. While most CSS has "something to do with typography", there are decorative, layout, or other variations that people choose to manage via CSS that have only marginal relation to typography.
Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.i18n-needs-resolutionIssue the Internationalization Group has raised and looks for a response on.selectors-4Current Work
Activity
svgeesus commentedon Mar 12, 2026
Do you want an earlier and simpler example in addition to this one, or is it so problematic that the whole example should be removed?
Would a selector that applies to Serbian (which is written in Cyrillic) and anything with a cyrillic subtag be a good additional example?
aphillips commentedon Mar 12, 2026
I think this is the early/simple example, with the meat of
:langdescribed later providing more extensive examples. Originally when I wrote this comment I did use Serbian+Cyrillic, but replaced it in the final comment. My thinking was: the use case for wanting to select "Serbian or anything written in Cyrillic" is pretty marginal (zh+*-hantis actually a more likely example, since several Sinitic languages can be written in Traditional Chinese). Since the goal is only to illustrate:langat a high level, I thought maybeen/*-CAmight serve well enough.This is fairly editorial and probably we should tag it as such.
frivoal commentedon Mar 13, 2026
I think Serbian or Cyrillic is a more realistic example than English or whatever from Canada. Not all, but most language based selection in CSS has something to do with typography, and that is much more closely correlated with script than with geography. That said, script is very often left out of language tags included in the markup, so there may not be much to select, since we don't do the kind of normalization that would fill in the blanks in that area.
aphillips commentedon Mar 13, 2026
That's also a potential gap. Elsewhere (CLDR, JS, etc.) the use of algorithms to improve matching and fallback is helpful and maybe we should discuss their use in the HTML/CSS space? This issue wouldn't be the place for that discussion, obviously. I'll consider another issue on the side for that.
Well... it depends on what one is trying to do. What makes the example funky is that selector authors are likely to do language or script or region, rather than mixing a language, a script, and a region in a single selector. We contrive the example to show that the
:lang()feature can do more than just a single, simple primary language tag.svgeesus commentedon Mar 31, 2026
I can see some people being upset that the example implies
enandfr-CAwould be treated the same.aphillips commentedon Apr 2, 2026
@svgeesus suggested that:
It doesn't imply that: it outright means that! 😉 Not only
fr-CA, butiu-CAandzh-CAand many more.An alternative to trying to find a "realistic" example of a primary-language-only + a wildcarded range with no primary would be to use more clearly unrealistic examples, like
E:lang(tlh, "*-Cyrl", "*-AQ")(Klingon, anything Cyrillic, anything Antarctica).@frivoal noted:
I mostly agree. Region-based presentation variations will mostly be divorced from the primary language. But then, so will script-based ones. While most CSS has "something to do with typography", there are decorative, layout, or other variations that people choose to manage via CSS that have only marginal relation to typography.
That said, I would be happy with
sr, *-Cyrl[selectors-4][editorial] Changed introductory :lang example from (zh,…
svgeesus commentedon Apr 9, 2026
Ok as there seemed to be general agreement on
sr, "*-Cyrl"I edited the introductory example to use that; I also tagged the change as editorial.@aphillips you already agreed, I know, but please confirm for the record
aphillips commentedon Apr 9, 2026
@svgeesus I'm good (satisfied)! Thanks!