EPUB 3 Accessibility Guidelines

Language

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).

Example

<html … lang="en" xml:lang="en">
   …
   <body>
      …
      <p>
         Harsh gargoyle face that warred against me 
         over our mess of hash of lights in 
         <span xml:lang="fr" lang="fr">rue 
         Saint-André-des-Arts</span>. In words of
         words for words, palabras. Oisin with
         Patrick. Faunman he met in Clamart woods,
         brandishing a winebottle.
         <i xml:lang="fr" lang="fr">C'est 
         vendredi saint!</i> Murthering Irish.
         His image, wandering, he met. I mine. I 
         met a fool i'the forest.
      </p>
      …
   </body>
</html>

Compliance References and Standards

Additional Resources

Frequently Asked Questions

Is it necessary to specify a default language in content files?

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.

Is it necessary to specify both the 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.