Invalid HTML lang attribute
This means that the URL in question has defined the language/region attribute using HTML lang, but either the language code or the geography code is invalid (or both are invalid).
Why is this important?
Some search engines, such as Bing, use the HTML lang attribute to help them determine which URLs to display in regional search results.
The "content" attribute is comprised of a 2-letter language code, followed by a dash and the appropriate geography code. For example:
- de-at: German, Austria
- de-de: German, Germany
- en-us: English, United States
In order to be considered valid, and recognised by search engines, the attribute value must conform to certain guidelines:
- The language code must be in ISO 639-1 format.
- The region code in your hreflang attribute must be in ISO 3166-1 format.
- Hypens must separate the language and region codes.
- The region code must not be used on its own (the language code can be).
- When used together, the language code must always proceed the region code.
If HTML lang does not conform to any of the above, it will not be recognised by search engines.
What does the Hint check?
This Hint will trigger for any URL that uses an invalid HTML lang attribute.
Examples that trigger this Hint:
Consider the URL: https://example.com/en/page-a/
The Hint would trigger for this URL if it had an invalid HTML lang attribute:
(where "en-uk" is invalid - it should be "en-gb")
How do you resolve this issue?
Invalid HTML lang will cause you issues in search engines that still support HTML lang (e.g. Bing), and they won't serve the correct localised content in different regions.
However, if you have set up hreflang correctly, this will supersede HTML lang (valid or not) for search engines that use hreflang (e.g. Google).