Page Design: Coding
Identify the Main Language
WAI Definition (Checkpoint 4.3)
Identify the primary language of the document text.
The primary language of a document is the natural language in which a document is written.
Screen readers need to know the natural language of a document in order for the words on the page to be pronounced correctly. Failing to identify the natural language could cause these devices to mispronounce the information making it impossible to understand. Identifying the natural language also improves search engine indexation.
The natural language should be identified in the <html> tag with:
- HTML 4.0: the "lang" attribute
- XHTML 1.0: "lang" and "xml:lang" attributes.
- XHTML 1.1: "xml:lang" attribute
The language codes for the six UN official languages are:
- Arabic: ar
- Chinese: zh
- English: en
- French: fr
- Russian: ru
- Spanish: es
Refer to the ISO list of language codes for additional languages.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> ....HTML document written in French... </html>
Check the source code.
The proper language code is set for the <html> tag (as seen in the example above in bold).