Menu

Communicate the language of your content

On this page

Screen readers have the ability to install different voices. Each voice is made to read a specific language. In this way, the nuance of a language can be conveyed. They can generally switch between different languages without any problems.

However, a screen reader cannot determine by itself in which language (part of) your content is formatted. If the language of the content is incorrect or not passed on, the text will be read in the wrong voice. For example, English text read in a Dutch voice will not be understandable.

It is therefore important that the author indicates in which language a page or document is formatted. We'll look at how you can set the correct language for different types of content. This way, your texts will be read out in correctly the appropriate voice.

HTML / Web pages

Within websites, you can indicate for the page, or a part of it, which language is being used. This can be done with the lang attribute.

At the page level

For a page, you place this attribute on the <html> element. With it, you indicate the (most used) language of the page. If your website is mainly formatted in English it will look like this in code:

Skip: Code example of an HTML element with the lang attribute indicating English content.
<html lang="en">
	<p>English content</p>
</html>
Code example of an HTML element with the lang attribute indicating English content.
Code example of an HTML element with the lang attribute indicating English content. skipped

At the content level

A page can, of course, have content in multiple languages. If, for example, you switch to Dutch for a piece of content, you can override it with the same lang attribute. This can be on the specific element, but also on a surrounding container if it contains multiple elements in that languages.

In code, this would like something like this:

Skip: Code example for Dutch content in an English page.
<html lang="en">
 	<p>English content</p>
	<p lang="nl">Dutch content</p>
 	<div lang="nl">
		<p> Dutch text</p>
		<a href="#">Dutch link</a>
	<div>
</html>
Code example for Dutch content in an English page.
Code example for Dutch content in an English page. skipped

Which language codes should you use?

In the lang attribute, you specify with language codes specifically what language it is. The best supported value for the lang attribute is a two-letter ISO 639-1 language code. Below are some examples:

ISO 639-1 CodeLanguage
enEnglish
nlDutch
deGerman
frFrench
itItalian
esSpanish
arArabic
trTurkish

Reading direction

The default reading direction for HTML is left to right. Some languages, such as Arabic, read from right to left. This information can be indicated by the dir="rtl" attribute.

Browsers can often determine this information automatically. Still, for mixed content, such as an Arabic quote in an English sentence, it is wise to apply this attribute to avoid unwanted results.

Support

Support for switching languages still leaves room for improvement, particularly when switching within text on the same page. Apart from using lang attributes correctly, there is little you can do without structuring your content specifically around these limitations.

Some parts may still be read in the wrong language even when the correct lang attribute is present.

Support is best for complete pages in another language, with the correct lang attribute on the html element.

The language must be installed

To switch to another language or dialect, the user must first have it installed. By default, only the system language used by the rest of the computer is available.

If a language is not installed, the default system language is used.

Translated text and screen reader instructions

Screen reader instructions do not switch language along with the content. A button with Dutch text can be read in a Dutch voice while its role is still announced as “button” in English, rather than “knop”. This is expected behaviour, but frequent switches can be confusing.

PDF documents

Within PDF documents, it is possible to assign a language both at file level and at element/code level. This can be done using Adobe Acrobat DC.

At the file level

Assigning the (main) language of a document can be done via the document properties. On the 'Advanced' tab, you will find the option 'language' at the bottom under 'Reading options'.

Language setting for a PDF in the document properties window

At the element/code level

Assigning a language in a PDF at element level is done via the properties window of the relevant code. You open this window with the following steps:

  1. Open the 'Codes' panel via 'View' - 'Show/Hide' - 'Navigation panes' - 'Codes'.
  2. Select the text of the relevant element on the page.
  3. In the 'Codes' panel, open the action menu and select 'Search code in selection'.
  4. Using the right mouse button, open the properties window of the highlighted code.
  5. In the Code tab, you can assign the language for the element at the bottom.
Language setting for an element in the object properties window