The default human language of each Web page can be programmatically determined. (Level A)
Description
Language is the medium to convey the information in the process of communication. It is also true in case of web content. The content of the web page may be written in a single language or in multiple languages. In either of the cases web page will have a default language which is otherwise called as primary language.
Often content authors forget to mention the language in which the content has to be rendered on the webpage. This may cause significant difficulties to certain user groups. Mentioning the primary language attribute on every web page is vital.
Declaring correct HTML language reference in web pages help technologies such as text to speech (TTS) synthesisers’ to provide accurate pronunciation to the users, helps the spell checking technologies to provide accurate results, user agents in rendering the content, language specific search engines to identify the information etc.
Who benefits with HTML language declaration?
- People who use screen readers
- People who use conventional user agents.
- People who have cognitive, language and learning difficulties.
- People who rely on captions for synchronized media.
How to declare language in HTML?
In the HTML tag of the web page use ‘lang’ attribute. In case of XML provide xml: lang attribute for language reference. Use both lang and xml:lang in case of XHTML 1.x or an HTML5 polyglot. Detailed information on how to declare HTML language attribute can be found at Working with language in HTML.
These language attributes should refer to HTML ISO language codes. Eg: The HTML language code for English is ‘en’, German is ‘De’, and French is ‘Fr’. W3Schools HTML ISO Language Code Reference provides a complete list of language codes.