Why it matters
- Screen readers choose a voice and a pronunciation by
lang: an English name in Arabic text, markedlang="en", is read with English pronunciation. A value such aslang="english"orlang="arabic"is not a language code, so nothing changes. - WCAG 2.2 asks that the language of each passage in another language can be determined (success criterion 3.1.2, level AA).
Example
<p>الدفع متاح بـ <span id="pay" lang="english">Apple Pay</span> لكل الطلبات.</p>
<p>الدفع متاح بـ <span id="pay" lang="en">Apple Pay</span> لكل الطلبات.</p>
How to fix
- Use a language code (BCP 47):
arfor Arabic,enfor English, with a region if you need one, such asar-OMoren-GB:<span lang="en">Apple Pay</span>.
How we detect
- We render the page and run axe-core 4.13.0's
valid-langrule in each engine. - It reports each element inside the page, not
<html>itself, whoselangdoes not start with a known language code. The<html>element's language is checked by the rule ar-html-lang. - It does not apply to pages with no
langattribute inside them.