Invalid language for part of page
When part of a page is marked as being in a different language, such as a quote in French on an English page, the language code must be written correctly. Silktide reports elements whose declared language is empty or not a recognizable code.
Why this matters
Marking a passage with its language lets a
switch pronunciation
mid-page, so a French quotation is read with French pronunciation rather than
mangled English. A broken declaration like lang="" or lang="french" defeats
this: software cannot act on it, and the passage is read with the wrong rules
or the reader's best guess.
This supports success criterion 3.1.2 (Language of Parts), a requirement, so it is part of the conformance target most organizations aim for.
How to fix it
Correct the lang attribute on each flagged element to a valid language code:
a two or three letter language, optionally followed by a region.
<!-- Problem: empty and invalid declarations -->
<blockquote lang="">Plus ça change...</blockquote>
<span lang="french">Plus ça change...</span>
<!-- Fix: a well-formed language code -->
<blockquote lang="fr">Plus ça change...</blockquote>
If the element is not actually in a different language, remove the lang
attribute instead - the element then inherits the page's language.
How Silktide tests this
- Find every element with a
langorxml:langattribute, apart from the page's root element, which is covered by the separate Invalid language for page check. - Report an attribute that is present but empty.
- Report an attribute whose value is not well-formed: the language part must
be 2 or 3 letters (such as
enorfr), and any region part that follows must be 2 or 3 letters (such asUSorGB). - Empty and malformed values are reported as distinct findings so you can see which problem each element has.
Troubleshooting
My language tag is valid but was reported
Silktide validates the language and region parts of the tag. Rarer forms of
valid tag, such as those with a four-letter script code like zh-Hans, can be
reported even though they are technically valid. If you confirm your tag is
correct, the finding.
The attribute comes from a third-party widget
Embedded widgets and consent banners sometimes inject empty lang attributes.
If you cannot change the widget's markup, raise it with the vendor, or approve
the finding.