Can elements that do not have a language set or inherited, meaning they are in an unspecified ("unknown") language, be targeted?
Facts
The language of an HTML document or element can be specified using the HTML lang
attribute, for example:
<html lang="en">
<h1>Dictionary</h1>
<dl>
<dt><abbr lang="en-Mors">-... - .--</abbr>
<dd><i lang="fr-Latn">à propos</i>
</dl>
or by including code(s) in the HTTP
Content-language header:
HTTP/2 200 OK
[other headers]
Content-language: en,en-Brai,fr-Latn
<html>
<h1>Dictionary</h1>
[rest of document]
or using the deprecated, yet still functional <meta http-equiv>
tag:
<html>
<head>
<meta http-equiv="content-language" content="en,en-Brai,fr-Latn">
</head>
<html>
<h1>Dictionary</h1>
[rest of document]
In all cases, the CSS selector :lang(en)
would target the main heading and other elements with no explicit lang
attribute set to "en".
Objective
If a document is sent without the Content-language HTTP header or <meta>
element, and without a lang
attribute, is it possible to target elements in the inevitable "unknown" language?
Furthermore, can the lang()
CSS selector be used to match elements with an empty lang=""
attribute, effectively opting out of having a language?
HTTP/2 200 OK
[no content-language header or meta present]
<html>
<p>I Want to select this. <span>And this.</span></p>
<p lang="">And this.</p>
<p lang="en">Not this. <span lang="">But this again.</span></p>
Methods that Do Not Work
Neither :lang()
, :lang(unknown)
, :lang('')
, nor :not(:lang(*))
work for this purpose. Selectors such as :not([lang]), [lang='']
would logically result in false negatives for scenarios involving the HTTP Content-language header/meta.
Answer Criteria
We are looking for an answer that either provides a solution without false negatives or confirms that it is impossible, with references to specifications (or their absence), along with an explanation of why this is the case.
Additional Notes:
When targeting the empty lang=""
attribute, using the selector [lang=""]
works, but may seem awkward given the dedicated :lang()
pseudo-class for language-related selections.