Specifying a document's default language — as well as any changes within the document, such as instances of foreign language terms or dialogue or passages in another language — helps ensure that assistive technologies can correctly render the text (e.g., that the correct braille characters are presented, or a voice capable of rendering the language gets used).
To define the default language for an XHTML document, the lang
and xml:lang
language attributes need to be attached to the root html
element. The language code defined
in these attributes should match one of the language codes specified in a dc:language
element in the package document's metadata section (see the faq for more
information).
When attached to elements within the body, the language attributes identify the language of the text content of that element (i.e., to identify a change in language).
The default language(s) for the publication are formally defined in the package document, but that information may not be available to assistive technologies depending on the reading system used. A cloud reader may only have access to the current XHTML content document, for example, in which case the proper language for braille rendering or TTS playback may not be available.
In the case of multilingual publications, it additionally may not be clear to any reading system or assistive technology which of the specified languages in the package document is the correct default for any given content document.
Best practice is to always specify the language in each content document to ensure proper rendering.
lang
and xml:lang
attributes?Again, for optimal accessibility both should be specified at this time. Assistive technologies may only recognize one or the other attribute.
In addition, if XHTML content documents are rendered as HTML by a reading system, only the
lang
attribute may be recognized.