HTML lang checker
Does your page declare its language with a code screen readers can use?
- Checks your page
- 3 browsers
- 2 rules
- Last updated
What we keep
The result appears here
Enter your page’s address and press “Check the page”. This is what the tool runs on it:
- Missing or wrong lang attribute on an Arabic pagenot started
- lang attribute that names no languagenot started
What it checks
- The
<html>element has a non-emptylangattribute when most of the page's text is Arabic. - The declared language is written in Arabic script, such as
arorar-SA, orfafor Persian andurfor Urdu, noten. - Each
langattribute on an element inside the page is a valid language code, such aslang="en", notlang="english".
Example
<html lang="en" dir="rtl"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>عن متجر العطور</title>
<html lang="ar" dir="rtl"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>عن متجر العطور</title>
How to fix
Declare the page's language on <html>, with its direction, and the language of each part in another language on its own element:
- Write the language code, not its name:
arfor Arabic andenfor English, notarabicorenglish. - Add a country code when the content is meant for one country, such as
ar-SA,ar-AEorar-OM. - In WordPress the attribute comes from the site language under "Settings → General"; other systems usually set it from their language settings or the theme template.
<html lang="ar" dir="rtl">
<body>
<p>الدفع متاح بـ <span lang="en">Apple Pay</span> لكل الطلبات.</p>
</body>
</html>FAQ
Declare Arabic on <html>, and put lang="en" on the elements that hold English text, such as a product name or a payment method: <span lang="en">Apple Pay</span>. The tool applies to a page when more than half of the letters in its visible text are Arabic.
No. Screen readers use the lang attribute, and a <meta http-equiv="content-language"> tag does not replace it. When the page has one, we list it in the result's evidence.
Because lang is not for Google alone: screen readers choose their voice and pronunciation from it, so an Arabic page declared as English is read with English pronunciation nobody can follow. Browsers rely on it for font choice and word-breaking rules, and may offer to translate a page already in the visitor's language. And WCAG 2.2 asks that the page's language be programmatically determined (success criterion 3.1.1), and the language of each passage in another language too (3.1.2).
What this tool runs
- Missing or wrong lang attribute on an Arabic pageserious
ar-html-lang - lang attribute that names no languageserious
a11y-valid-lang
How we measure
We fetch the page as ArablyzerBot, following its redirects, and read the HTML as the server sends it, before any JavaScript runs, decoding it as browsers do, older windows-1256 pages included. We count the letters in the visible text; when more than half of them are Arabic, we read the lang attribute of <html>, which passes when it declares a language written in Arabic script, such as Arabic, Persian or Urdu, or any tag with -Arab. Then we render the page in Chromium, Firefox and WebKit, each behind Arablyzer's egress proxy, and run axe-core 4.13.0's valid-lang rule on the rendered page: it reports each element inside it, other than <html>, whose lang does not start with a known language code. The same page gives the same result on every check.