The lang attribute tells browsers and search engines what language a page is written in. If it is missing or incorrect, search engines may show the page to the wrong audience, screen readers may mispronounce content, and SEO signals may be weakened. In this guide, you will learn what the lang attribute is, why it matters, how to check it, and how to fix common issues.
What is the lang attribute
The lang attribute is an HTML attribute that specifies the language of a page or a specific element. It is usually set on the <html> tag:
<html lang="en">
The value is a language code. For English — en. For Russian — ru. For German — de. For regional variations — en-US (American English), en-GB (British English), pt-BR (Brazilian Portuguese).
The lang attribute can also be set on individual elements if the language changes within the page. For example, a quote in French inside an English page:
<blockquote lang="fr">...</blockquote>
Check the lang attribute via the language attribute checker.
Why the lang attribute matters
Four reasons.
1. SEO. Search engines use the lang attribute to understand the language of a page and show it to the right audience. If the attribute is missing or wrong, the page may be shown to users who do not speak that language.
2. Accessibility. Screen readers use the lang attribute to pronounce content correctly. Without it, a screen reader may read English text with Russian pronunciation rules, making it unintelligible.
3. Browser features. Browsers use the lang attribute for spell-checking, hyphenation, and font selection. If it is missing, these features may not work correctly.
4. Translation tools. Browser translation tools use the lang attribute to detect the page language. If it is wrong, the tool may offer the wrong translation.
For multilingual sites, the lang attribute is critical. Combined with hreflang, it helps search engines understand the relationship between language versions.
How to check the lang attribute
Three ways.
Method 1. Language attribute checker tool
The fastest way is to use an online language attribute checker. The SerpMax language attribute checker tests any URL and shows:
— whether the lang attribute is present;
— its current value;
— whether the value matches the page content;
— recommendations for fixing issues.
The tool works with any website.
Method 2. View page source
Open the page in a browser. Right-click and select "View page source". Look at the first line — the <html> tag should have a lang attribute:
<html lang="en">
If there is no lang attribute, or the value is wrong, you need to fix it.
Method 3. Chrome DevTools
Open Chrome DevTools (F12). In the Elements tab, select the <html> element. Check the lang attribute in the panel on the right.
You can also run this in the Console:
document.documentElement.lang
This returns the current lang value.
Common lang attribute issues
Five common problems.
1. Missing lang attribute
The most common issue. The <html> tag has no lang attribute. Search engines and screen readers have to guess the language.
How to fix: Add the lang attribute to the <html> tag. For an English page — lang="en". For Russian — lang="ru".
2. Wrong language code
The lang attribute uses the wrong code. For example, lang="eng" instead of lang="en", or lang="english" instead of lang="en". Only ISO 639-1 codes are valid.
How to fix: Use the correct two-letter code. Check the ISO 639-1 list for valid codes.
3. Language mismatch
The lang attribute says en but the page content is in Russian. Search engines may show the page to English-speaking users, who will bounce.
How to fix: Set the lang attribute to match the page language.
4. Same lang on multilingual pages
If a site has English and Russian versions, both should have different lang attributes. If both have lang="en" — the Russian version is mislabeled.
How to fix: Set the correct lang for each language version.
5. Missing regional codes
If content targets a specific region, use a regional code. For example, en-US for American English, en-GB for British English. Without the region, search engines may show the page to the wrong audience.
How to fix: Add the region code where relevant. Use en-US, en-GB, pt-BR, and so on.
Lang attribute and hreflang
The lang attribute and hreflang work together but serve different purposes.
Lang attribute tells browsers and search engines what language a page is in. It is set in the HTML.
Hreflang tells search engines about alternate language versions of the same page. It is set in the HTML head or in HTTP headers.
For multilingual sites, both are needed. The lang attribute sets the language of each version. Hreflang connects the versions so search engines understand they are alternates, not duplicates.
Without hreflang, multilingual pages may compete with each other in search results. Learn more about multilingual SEO in the article Multilingual Site SEO and Hreflang.
How to fix the lang attribute
If the lang attribute is missing or wrong, fix it in the HTML template.
Step 1. Open your site template. Find the <html> tag.
Step 2. Add or correct the lang attribute:
<html lang="en">
Step 3. If the site is multilingual, set the correct lang for each language version.
Step 4. Save the template and check the page via the language attribute checker.
If you use a CMS, the lang attribute is usually set in the theme settings. For WordPress — in the theme header file or via a plugin. For other CMS — in the template settings.
How to check the lang attribute across your site
Checking every page manually is slow. For a site with 100+ pages, use the SEO Audit by SerpMax. The tool crawls all pages and shows:
— pages with missing lang attributes;
— pages with incorrect language codes;
— pages where lang does not match content;
— recommendations.
This gives you a complete list of issues in one report.
How often to check the lang attribute
Recommended frequency:
— Before publishing a new page — check the lang attribute manually.
— After a redesign or CMS migration — lang attributes are often lost during migrations.
— Once a month — run a full site audit via SEO Audit by SerpMax.
— If you notice SEO issues on multilingual pages — check lang and hreflang together.
Frequently Asked Questions
What is the lang attribute?
The lang attribute is an HTML attribute that specifies the language of a page. It is set on the <html> tag, for example: <html lang="en">. It uses ISO 639-1 language codes.
Why does the lang attribute matter for SEO?
Search engines use it to understand the page language and show it to the right audience. If missing or wrong, the page may be shown to users who do not speak that language, increasing bounce rate.
How do I check the lang attribute?
Use the language attribute checker. Or view the page source and check the <html> tag. Or use Chrome DevTools Console: document.documentElement.lang.
What is the difference between lang and hreflang?
The lang attribute tells search engines what language a page is in. Hreflang tells search engines about alternate language versions of the same page. Both are needed for multilingual sites.
What happens if the lang attribute is missing?
Search engines and screen readers have to guess the language. This may lead to wrong audience targeting, mispronunciation by screen readers, and weaker SEO signals.
Can I set the lang attribute on individual elements?
Yes. If the language changes within a page, you can set the lang attribute on specific elements. For example, a quote in French inside an English page: <blockquote lang="fr">.
Should I use regional codes like en-US?
Yes, if content targets a specific region. For example, use en-US for American English, en-GB for British English. Without the region, search engines may show the page to a broader audience.
How often should I check the lang attribute?
Before publishing new pages, after redesigns or migrations, and once a month as part of a technical SEO audit. Missing or wrong lang attributes are common after site changes.