Skip to content
SilktideHelp

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 recognisable 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 organisations 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 \u00e7a change...</blockquote>
<span lang=\"french\">Plus \u00e7a change...</span>

<!-- Fix: a well-formed language code -->
<blockquote lang=\"fr\">Plus \u00e7a 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

  1. Find every element with a lang or xml:lang attribute, apart from the page's root element, which is covered by the separate Invalid language for page check.
  2. Report an attribute that is present but empty.
  3. Report an attribute whose value is not well-formed: the language part must be 2 or 3 letters (such as en or fr), and any region part that follows must be 2 or 3 letters (such as US or GB).
  4. 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.

Learn more

Last updated

Was this page helpful?

Invalid language for part of page | Silktide Help