Skip to content

[selectors-4] :lang example needs refinement #13644

Closed

Description

@aphillips

Selectors Overview
https://www.w3.org/TR/2026/WD-selectors-4-20260122/#overview

| 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)

Activity

  1. added
    selectors-4
    i18n-needs-resolution
    on Mar 12, 2026
  2. svgeesus commented on Mar 12, 2026

    @svgeesus
    Collaborator

    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?

  3. aphillips commented on Mar 12, 2026

    @aphillips
    ContributorAuthor

    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.

  4. frivoal commented on Mar 13, 2026

    @frivoal
    Collaborator

    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.

  5. aphillips commented on Mar 13, 2026

    @aphillips
    ContributorAuthor

    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.

  6. svgeesus commented on Mar 31, 2026

    @svgeesus
    Collaborator

    an element of type E tagged with a language tag for English (en) or any language tag with the region Canada (*-CA)

    I can see some people being upset that the example implies en and fr-CA would be treated the same.

  7. aphillips commented on Apr 2, 2026

    @aphillips
    ContributorAuthor

    @svgeesus suggested that:

    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).

    @frivoal noted:

    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.

    That said, I would be happy with sr, *-Cyrl

  8. svgeesus commented on Apr 9, 2026

    @svgeesus
    Collaborator

    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

  9. aphillips commented on Apr 9, 2026

    @aphillips
    ContributorAuthor

    @svgeesus I'm good (satisfied)! Thanks!

  10. added
    Commenter Satisfied
    on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Commenter Satisfiedi18n-needs-resolutionselectors-4

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo