Html Has Lang
Critical - WCAG Level A
The issue at hand is the absence of the lang attribute in the HTML document. This attribute is crucial as it specifies the primary language of the content, enabling assistive technologies, such as screen readers, to interpret and vocalize the text correctly. Without this attribute, users who rely on these technologies may experience mispronunciations or confusion, leading to a frustrating experience.
To fix this issue:
Identify the primary language of your content. This is typically the language in which the majority of the text is written.
Add the
langattribute to the<html>tag of your document. The value should be the appropriate language code as per the IETF BCP 47 standard (e.g.,enfor English,frfor French,esfor Spanish).Consider the use of
langattributes on specific elements if your document contains multiple languages. For example, if you include a quote in a different language, use thelangattribute on that specific element.
Best Practices:
Always use the most specific language code available (e.g.,
en-USfor American English).If your page includes content in multiple languages, use the
langattribute on those specific elements as well to ensure accurate pronunciation.
Common Mistakes:
Forgetting to include the
langattribute altogether.Using an incorrect or generic language code that does not accurately represent the content's language.
Not updating the
langattribute when the primary language of the content changes.