HTML (<html>)

When To Use 

  • The HTML tag serves as the top-level container for an HTML file. 1

Rules

  • You need to specify a lang attribute on the root html element to indicate the document‘s primary language. This helps speech synthesis and translation tools determine proper pronunciation and usage rules. 1 This is a A level requirement of the WCAG 2.1 guidelines. 2
  • Your language code should be a short as possible. So only use a region subtag if it is really necessary. 4
  • All language codes are provided in the IANA Language Subtag Registry.
  • Make sure to use the lang attribute on elements that are in different language than the default one set on the html element. Single common words of another language do not need to be declared. But use as soon as you have a complete sentence in another language. This is a AA level requirement of the WCAG 2.1 guidelines. 3

Sources 

  1. HTML Spec: Living Standard, 4 The elements of HTML is licensed under Creative Commons Attribution 4.0 International License
  2. W3C: Language of Page (Level A) by Accessibility Guidelines Working Group (AG WG) Participants is licensed under W3C Document License
  3. W3C: Language of Parts (Level AA) by Accessibility Guidelines Working Group (AG WG) Participants is licensed under W3C Document License
  4. W3C: Choosing a Language Tag by Richard Ishida
Created at: 28.04.2023, Last updated at: 11.06.2023