Website problems
Missing language declaration
The `lang` attribute on the `<html>` element declares the natural language of a page's content. Without it, a screen reader falls back to the user's default voice and may pronounce the page in the wrong language, and translation tools have to guess the source. It is a single attribute with a two-letter value, it is a Level A requirement in WCAG, and declaring the wrong language is worse than the attribute being absent.
What depends on it
Screen-reader pronunciation, first and most concretely. A French page read by a voice set to English is close to unintelligible — the words are pronounced with English phonetics and the result is not French or English.
Automatic translation. Browsers and translation services use the declared language to decide whether to offer a translation and what to translate from.
Hyphenation and line-breaking rules in CSS, which are language-dependent.
Font selection, where a browser picks different glyphs for the same characters depending on the declared language — visible in CJK text in particular.
Search engines mostly determine language from the content rather than the attribute, so this is an accessibility and user-agent concern more than a ranking one.
The value, precisely
`lang` takes a BCP 47 language tag. `en`, `fr`, `de` are valid; so are `en-GB` and `pt-BR` where the regional distinction matters.
Use the shortest tag that is accurate. `en` is right unless the difference between British and American English matters to pronunciation or spelling conventions on that page.
A region subtag alone is not a language: `lang="uk"` means Ukrainian, not United Kingdom. This is a recurring mistake and it produces a confidently wrong pronunciation.
Where part of a page is in another language, mark that part: `<span lang="fr">` inside an English page tells the screen reader to switch voices for that phrase and switch back.
In HTML documents served as `text/html`, `lang` alone is sufficient; `xml:lang` is for XML serialisations and adding both to an HTML page achieves nothing.
The related attribute is `dir`, which declares text direction. A page in Arabic or Hebrew needs `dir="rtl"` as well as its `lang` value — the language tag alone does not reverse the layout.
The wrong value is worse than none
With no attribute, assistive technology falls back to the user's own setting, which for most users is the language they actually read.
With a wrong attribute, it obeys. A German page declaring `lang="en"` is read aloud in English phonetics with confidence, and the user has no way to override it short of changing their own settings.
The common cause is a multilingual site whose template hardcodes the language of whichever locale was built first. Every translated page then declares the original language.
This is why the check worth running on a multilingual site is not 'is the attribute present' but 'does it match the language of the text'.
How to check it yourself
`document.documentElement.lang` in the console returns the value, or an empty string.
In the source, the attribute is on the opening `<html>` tag: `<html lang="en">`.
On a multilingual site, check one page per language rather than one page. A hardcoded value passes the presence test on every page and is wrong on all but one.
Browser developer tools' accessibility pane shows the computed language for an element, which is how you confirm that an inline `lang` on a quoted passage is taking effect.
How to fix it
Set it in the base template, from the same variable that decides the page's locale. A hardcoded literal in a multilingual template is the defect, not the fix.
Use the language of the main content, not of the site's administrative default.
Add inline `lang` on passages in another language — quotations, product names in their original language, a paragraph left untranslated.
Do not add `lang` to elements purely to change the font. That is a CSS decision, and a false language declaration changes pronunciation for everyone using a screen reader.
How VeriFixScan detects it
`seo.lang` reads the `<html>` element of every crawled page and reports pages with no `lang` attribute, along with the value where one is present.
The scanner also flags a declared language that does not match the language of the page's text, which is the case that matters on a translated site and the one a presence check misses entirely.
The mismatch detection compares the declared tag against the content; it identifies a disagreement rather than deciding which of the two is correct.
Frequently asked questions
- Does the lang attribute affect SEO?
- Very little. Google determines the language of a page from its content rather than the attribute. The reasons to set it are pronunciation, translation and text rendering.
- Is lang the same as hreflang?
- No. `lang` declares the language of this document to the browser and assistive technology. `hreflang` tells search engines that alternative language versions of this page exist at other URLs.
- Should I use en or en-US?
- Use the shortest accurate tag. `en` is right unless the regional distinction matters on that page; over-specifying gains nothing and can be wrong.
Sources
Related
VeriFixScan crawls a site and applies its checks to every page it reaches, keeping the evidence behind each finding. Scanning one website is free.
Scan a website