Identify non-English text

If the text in your website uses multiple languages, you'll want to indicate what language is being displayed. The lang attribute is used to identify chunks of text in a language that is different from the document’s primary language. 

All sites on Stanford Sites are by default in English, and screen readers will announce the text in English. If there is non-English text, you can use a lang attribute to identify the correct language of text, and the screen reader will announce text in that language. 

For example, given this text in French:

Sauf pour ce qui est écrit en mauvais français.

Using inspect through the browser, you can see the lang attribute in action. 

<p lang="fr">Sauf pour ce qui est écrit en mauvais français.</p>

Add the lang attribute to non-English text

The text editor makes it easy to add the lang attribute to a single word or an entire paragraph. 

  1. Select the the non-English text. Note that if the text is not contiguous, you will need to repeat this for each part.
  2. Click on the Show more items button (the three vertical dots ( ⋮ )) at the end of the tool bar to bring up the Choose Language dropdown menu.
  3. Scroll through the menu to find the appropriate language and click on it. Within the text editor, you should see the associated language attribute displayed in small font at the end of the word, list item, paragraph, etc.

Note: to see the lang attributes on a published page, you can use the browser Inspect tool to view the underlying HTML.

 

Note: When the lang attribute is missing, it violates SC 3.1.1:Language of Page (Level A).

Lang attribute resources

Related Topics