Is it possible to target elements that have no language set nor inherited, i.e. are in unspecified ("unknown") language?
Trivia
HTML document or element language can be set using HTML lang
attribute, e.g.:
<html lang="en">
<h1>Dictionary</h1>
<dl>
<dt><abbr lang="en-Mors">-... - .--</abbr>
<dd><i lang="fr-Latn">à propos</i>
</dl>
or using 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 it's long deprecated yet still working <meta http-equiv>
counterpart:
<html>
<head>
<meta http-equiv="content-language" content="en,en-Brai,fr-Latn">
</head>
<html>
<h1>Dictionary</h1>
[rest of document]
In either case using :lang(en)
CSS selector matches main heading from examples and all other elements that has not explicit lang
attribute with value not equal or starting with "en".
Goal
In case the document is sent without Content-language
HTTP header or <meta>
element and without lang
attribute, is it possible to match those elements that falls to inevitable "unknown" language?
Plus in document or DOM fragment that has language set by any aforementioned mean, is it possible to use lang()
CSS selector to match elements with empty lang=""
attribute, that effectively 'opts out' of having language?
HTTP/2 200 OK
[no content-language header nor 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>
What does not work
Neither :lang()
, :lang(unknown)
, :lang('')
nor :not(:lang(*))
works for this purpose. Selectors derived from :not([lang]), [lang='']
would logically give false negative for use-cases with HTTP Content-language header/meta present.
Answer requirements
Seeking answer that either gives solution without false negatives or confirms it is not possible with references to specs (or their absence) and explanation why is it so.
Notes:
When empty lang=""
attribute is present, targeting it with [lang=""]
attribute selector works, but feels weird considering there is dedicated :lang()
pseudo-class for language-related stuff.