Page and Inline Language
The language of every document or web page must be correctly set. For documents, this is set in the file properties. For web pages, this is set as an attribute on the HTML element. For a page primarily in English, use lang="en":
<html lang="en">If the primary language is not English, find and use the correct language code. These codes are defined by the ISO 639-1 standard and are the two-digit codes listed in the Codes for the Representation of Names of Languages from the Library of Congress. For example, Spanish is es and Chinese is zh.
Inline Changes
In addition to setting the page-level language, language changes in smaller sections must be identified and set correctly. Add the lang attribute with the correct value to an element containing the different language text. In the following example, there is a language change mid-sentence. Listen to these audio examples to hear the difference between how the JAWS screen reader reads the sentence without and with a correctly set language change:
<p>Pablo Picasso said "La acción es la clave fundamental para todo éxito" which translates to "Action is the foundational key to all success."</p><p>Pablo Picasso said <span lang="es">"La acción es la clave fundamental para todo éxito"</span> which translates to "Action is the foundational key to all success."</p>The language change only applies to content inside that element. If you have multiple consecutive paragraphs in a different language from the rest of the page, each paragraph needs the lang element added and set to the correct value:
<p lang="es">Párrafo de ejemplo en Español</p>
<p lang="es">Otro párrafo de ejemplo en Español</p>Alternatively, because the language applies to all children beneath it, it can be set on a parent element:
<div lang="es">
<p>Párrafo de ejemplo en Español</p>
<p>Otro párrafo de ejemplo en Español</p>
</div>Regional Dialects
It is possible to add a regional extension to the language code, such as British English (en-uk) versus American English (en-us). Unless there is a specific reason to do so, do not set the regional dialect, as this can interfere with screen readers.
