--- url: "https://www.w3.org/WAI/WCAG22/Techniques/html/H58" titulek: "H58: Using language attributes to identify changes in the human language | WAI | W3C" h1: "Technique H58:Using language attributes to identify changes in the human language" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 06:28:26" znaku: 3468 slov: 468 kodovani: "utf-8" sha256: "e8d2469446a9cacca8305c1fedb945eff9890e58ead6dbd0f4c6e6ccdf8abd6e" --- # Technique H58:Using language attributes to identify changes in the human language ## About this Technique This technique relates to [3.1.2 Language of Parts](https://www.w3.org/WAI/WCAG22/Understanding/language-of-parts) (**Sufficient**). This technique applies to HTML. Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The objective of this technique is to clearly identify any changes in language on a page by using the `lang` attribute. Allowed values for the `lang` attribute are indicated in the resources referenced below. Language tags use a primary code to indicate the language, and optional sub-codes (separated by hyphen characters) to indicate variants of the language. For instance, English is indicated with the primary code `"en"`; British English and American English can be distinguished by using `"en-GB"` and `"en-US"`, respectively. Use of the primary code is important for this technique. Use of sub-codes is optional but may be helpful in certain circumstances. ## Examples ### Example 1: The use of the `lang` attribute to define a quote written in German ```

Da dachte der Herr daran, ihn aus dem Futter zu schaffen, aber der Esel merkte, daß kein guter Wind wehte, lief fort und machte sich auf den Weg nach Bremen: dort, meinte er, könnte er ja Stadtmusikant werden.

``` ## Related Resources *No endorsement implied.* - [HTML - The `lang` and `xml:lang` attributes](https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes) . - [HTML "`lang`" attribute on the Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) . - [BCP 47: Tags for Identifying Languages; Matching of Language Tags](https://www.rfc-editor.org/info/bcp47) . - [Language tags in HTML and XML](https://www.w3.org/International/articles/language-tags/) . - [Declaring language in HTML](https://www.w3.org/International/questions/qa-html-language-declarations) ## Tests ### Procedure For each element in the document: 1. Check that the human language of the content of the element is the same as the inherited language for the element as specified in [HTML - The `lang` and `xml:lang` attributes](https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes) . For each `lang` attribute in the document: 1. Check that the value of the `lang` attribute conforms to [BCP 47: Tags for Identifying Languages; Matching of Language Tags](https://www.rfc-editor.org/info/bcp47) or its successor. 2. Check that the language code matches the language of the content it applies to. ### Expected Results - All checks above are true. ## Test Rules The following are Test Rules related to this Technique. It is not necessary to use these particular Test Rules to check for conformance with WCAG, but they are defined and approved test methods. For information on using Test Rules, see [Understanding Test Rules for WCAG Success Criteria](https://www.w3.org/WAI/WCAG22/Understanding/understanding-act-rules.html). - [Element with lang attribute has valid language tag](/WAI/standards-guidelines/act/rules/de46e4/) - [HTML element language subtag matches language](/WAI/standards-guidelines/act/rules/off6ek/proposed/) Back to Top