Re: [csswg-drafts] [selectors-4] Clarify :lang() behavior when the language range is not a well-formed BCP 47 code (#8720)

This won't work.

Language **_tags_** can be well-formed and can be valid. But _extended language ranges_ use a different, much more permissive syntax. See: https://www.rfc-editor.org/rfc/rfc4647.html#section-2.2

Using a language range that does not consist of a well-formed language tag doesn't make it match better, which is what you're trying to get at. 

However, extended language ranges permit the wildcard `*` in any subtag position. Canonically, only the first ("primary language subtag") position matters. Other wildcards normalize away when the range is parsed. But your text won't work. It should say something like:

> A _language range_ must be an extended language range according to BCP47.
> Language ranges that are not [well-formed language tags](https://www.w3.org/TR/i18n-glossary/#dfn-well-formed)
> or which would not be a well-formed language tag if an initial wildcard character `*` were replaced with a 
> valid subtag do not match anything.

In practice, it is probably easier to say that ranges that don't make the RFC4647 section 2.2 syntax fail and leave it at that. While ranges like "English" and "1234-banana" are invalid as language tags, they also won't match anything productively. 

-- 
GitHub Notification of comment by aphillips
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8720#issuecomment-4291664741 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 21 April 2026 20:46:40 UTC