Picto thématique

Rule n° 125 - Each page’s source code indicates the content’s main language.

A web page is written in a language that is not necessarily identifiable by the tools that analyse the pages. This information must be introduced to all automatic tools by the source code of the pages.

#Accessibility #SEO #Internationalization #Development

Goal

  • Cultivate content indexing by language.
  • Facilitate machine translation.
  • Enable correct reading of the content by a synthesized speech tool.
  • Improve the accessibility of content for people with disabilities.
  • Improve the way content is taken into account by search engines and indexing tools.

Implementation

Fill in the lang attribute of the html root element using the appropriate language code (as indicated in the registry maintained by IANA: http://www.iana.org/assignments/language-subtag-registry). In practice, for French this is: <html lang="fr"> (in HTML) et <html lang="fr" xml:lang="fr"> (in XHTML).

Otherwise, in more complex cases, the content language can be indicated by the different parent elements: head, body, title, etc.

Find out more:

Control

Verification consists in checking that the lang attribute of the html element is present and relevant (or failing that check its descendant elements) in the source code. In the source code of each page:

  • Check that the default language of the content is indicated by the lang attribute of the html element, for example <html lang="fr"> (in HTML)
  • If not, check for each content element that is is at least inherited form a parent element (head, body, title, etc.) from its langattribute.

Check the validity and relevance of the language code used. For this, use for example the Language Subtag Lookup Tool by Richard Ishida, https://r12a.github.io/app-subtags/.

Common cases of incorrect language codes include jp instead of ja for Japanese, lu instead of lb for Luxembourgish, gr instead of el for Greek, lat instead of la for Latin, and oci instead of oc for Occitan. Additionally, the codes mul for "multiple languages" and und for "undetermined language" must not be used in web content. Finally, the xml:lang can also be entered in addition to the lang attribute, but it is not sufficient to comply with this best practice.

By Opquast - Read the license

Business application and benefits

The rules should be applied to your projects from the design phase through to post-implementation , and they should be understood by all professionals with web and customer experience (CX) responsibilities: from strategy to operations, marketers to project managers, and editorial to technical staff. The benefits of using this ruleset are numerous, including improving customer satisfaction, web performance, and e-commerce, and expanding your client base, while also decreasing your errors and costs.

Multidisciplinary verticles - accessiiblity, SEO, e-commerce, ecodesign etc..- starting from the foundational Opquast base.

The objective of these rules and the Opquast community mission is ‘making the web better’ for your customers and for everyone! Opquast rules cover the key major areas of risk that can negatively affect website users such as privacy, ecodesign, accessibility and security.

Opquast training has already allowed over 11,000 web professionals to have their skills certified. Train your teams or your students, contact us