How to Add the HTML lang Attribute to Your Website

Add the HTML lang attribute so search engines and screen readers know your page's language — exact steps for WordPress, Wix, Squarespace, Webflow and custom sites.

Nasir Uddin
Nasir UddinSEO & Growth Lead · ScoutRival
How to Add the HTML lang Attribute to Your Website — cover
On this page

If ScoutRival’s SEO Score flagged “Declare the page language,” it means your pages are missing the lang attribute on the <html> tag — so nothing on the page formally states what language it’s in. It’s one of the smallest fixes on your whole checklist, usually a two-minute change, and this guide shows you exactly how to do it on every major platform, no coding required.

What is the HTML lang attribute?

The HTML lang attribute is a small setting you add to the opening <html> tag of a web page to declare the page’s primary language. In code it looks like <html lang="en">, where en is the two-letter code for English.

Think of it like the language label on a product box. The words inside might be French, Spanish or English — but the label on the outside tells anyone picking it up which language to expect before they even open it. Search engines and screen readers read that label first, so they know how to handle everything that follows.

Here’s why that label matters in practice. A screen reader (the software blind and low-vision visitors use to have pages read aloud) picks a voice and pronunciation based on the lang attribute. If your English page is missing it — or worse, has the wrong code — the reader may pronounce your content with the wrong accent or in the wrong language entirely, making it hard to understand. Search engines use the same signal to confirm which audience your page is meant for.

The attribute takes a standard language code: en (English), es (Spanish), fr (French), de (German), and so on. You can be more specific with a region — en-US (American English), en-GB (British English), pt-BR (Brazilian Portuguese) — but for most single-language sites, the simple two-letter code is all you need.

Why it matters for your SEO

The lang attribute won’t rocket you up the rankings on its own — it’s a low-severity, foundational signal. But leaving it out causes two quiet problems:

  • Accessibility gaps. Missing or wrong language declarations are a common accessibility failure. Screen readers can’t choose the right voice, which hurts real users and can flag issues in accessibility audits. Since Google factors page experience and accessibility signals into how it evaluates sites, this is worth getting right.
  • Ambiguous language targeting. Google is good at detecting language from your words, but an explicit declaration removes doubt — especially useful if your page mixes languages, uses a lot of brand names, or serves a specific regional audience. It helps your page reach the right people in the right region.

ScoutRival’s SEO Score checks each page for a lang attribute on the <html> tag. If it’s absent, the check fails — and the simple fix below clears it and nudges your On-page pillar score up.

How to check if you have this problem

You can confirm this in about 30 seconds:

  1. Open the page you want to check in your browser.
  2. Right-click anywhere on the page and choose View Page Source (or press Ctrl+U on Windows / Cmd+Option+U on Mac).
  3. Look at the very top of the code — the first <html ...> tag.
  • You see <html lang="en"> (or another valid code) → you’re set. Just confirm the code matches your content’s actual language.
  • You see a bare <html> with no lang, or a wrong code (an English page marked lang="fr") → that’s the problem this guide fixes.

You can also use your browser’s built-in accessibility or “Inspect” tools, but View Page Source is the fastest manual check. Of course, running your ScoutRival SEO Score checks this automatically across every page at once, so you don’t have to inspect each one by hand.

How to fix it — step by step

The exact code you’re aiming for is a single attribute on the <html> tag:

<html lang="en">

Swap en for your content’s real language code. Pick your platform below.

WordPress

WordPress sets the lang attribute automatically from your site’s language setting — so this is usually a menu choice, not a code edit:

  1. Go to Settings → General in your WordPress dashboard.
  2. Find Site Language and select the correct language (e.g. English (United States) or English (UK)).
  3. Save. WordPress will now output the matching lang attribute on your <html> tag site-wide.
  4. If the attribute is still missing after that — usually because a custom or heavily modified theme hard-codes its own <html> tag — check your theme’s header.php file and make sure it uses <html <?php language_attributes(); ?>> rather than a plain <html>.

Wix

  1. In your Wix dashboard, go to Settings → Language & Region (or Settings → Business Info depending on your dashboard version).
  2. Set your site language to the correct language.
  3. Wix applies the matching lang attribute for you. If you run a multilingual site with Wix Multilingual, each language version automatically gets its own correct lang code.

Squarespace

Squarespace sets the page language from your site language setting:

  1. Go to Settings → Language & Region.
  2. Choose your site language from the dropdown (e.g. English).
  3. Save. Squarespace outputs the matching lang attribute on your pages automatically — you don’t edit code for this.

Webflow

Webflow lets you set the site language directly, which controls the lang attribute:

  1. Open Project Settings → General (or Site settings → General in newer editors).
  2. Find the HTML lang attribute / Site language field and enter your language code (e.g. en, or en-US for a region).
  3. Click Save changes, then Publish your site so the update goes live.

Shopify

Shopify themes set the lang attribute from your store’s language, and support multiple languages:

  1. Go to Settings → Languages (under Store details / Preferences depending on your admin).
  2. Confirm your default language is correct; add and publish other languages here if you sell in more than one.
  3. Shopify’s themes output the right lang automatically. If you use a custom theme where it’s missing, open Online Store → Themes → Edit code, open theme.liquid, and make sure the <html> tag reads <html lang="{{ request.locale.iso_code }}"> rather than a plain <html>.

Any other website (custom or unlisted CMS)

If you hand-code your site or use a builder not listed above, add the attribute directly to your base template:

  1. Open the file that renders your page’s outer HTML shell — often index.html, a layout file, or your framework’s root template.
  2. Find the opening <html> tag near the top.
  3. Add the lang attribute with your content’s language code:
<html lang="en">
  1. Save and re-publish. Because it lives in the shared shell, one edit usually covers every page on the site. For multilingual sites, output the correct code per language version.

How to confirm it’s fixed

  1. Reload the page and open View Page Source again — the first <html> tag should now include your lang attribute.
  2. Double-check the code matches the content: an English page should say lang="en", not lang="fr".
  3. Re-run your ScoutRival SEO audit. The “Declare the page language” item should now pass, and your On-page pillar score should tick up.

Common mistakes to avoid

  • Using the wrong code. Declaring lang="en" on a Spanish page is worse than declaring nothing — it actively misleads screen readers. Match the code to the words on the page.
  • Confusing language and region. en is English; en-GB is British English specifically. Use the region form only when it’s meaningful; plain en is fine for most sites.
  • Made-up or invalid codes. Use standard ISO codes (en, es, fr, de, zh, ar…) — not english or eng.
  • Overwriting the builder’s setting with a hard-coded tag. If your platform sets lang automatically, don’t paste a second <html> tag in a code block — you’ll end up with a conflict.
  • Forgetting multilingual versions. If you serve the same content in several languages, each version needs its own matching lang code, not one blanket value.

The bottom line

The HTML lang attribute is one of the smallest lines of code on your site, but it’s a real signal to search engines and a genuine help to visitors using screen readers. Set your site language in your platform’s settings (or add <html lang="en"> to a custom template), confirm it in your page source, and you’ve cleared another quick win off your SEO checklist.

Want to see every page missing this and other fast fixes at a glance? Run a free SEO Score with ScoutRival and get a prioritised, plain-English to-do list for your whole site. While you’re tidying up your page structure, our guide on the correct heading structure for SEO is a natural next step.

Frequently asked questions

What is the HTML lang attribute?
The HTML lang attribute is a setting on the opening `<html>` tag that declares a page's primary language, such as `<html lang="en">`. It tells search engines and screen readers which language your content is in so they can index and read it correctly.
Where do I put the lang attribute?
It goes on the root `<html>` element — the opening tag at the very top of your page's code — not on individual paragraphs or sections. On most website builders it's set automatically from your site language setting rather than edited by hand.
What language code should I use?
Use the standard ISO code for your content's language: `en` for English, `es` for Spanish, `fr` for French, `de` for German. Add a region only when it matters, like `en-GB` for British English or `en-US` for American English.
Does the lang attribute affect SEO?
It's a small, foundational signal rather than a major ranking factor. It mainly improves accessibility and removes ambiguity about which audience and language your page targets, which supports how correctly search engines handle your page.
How do I set the page language in WordPress?
Go to Settings → General, choose the correct Site Language, and save. WordPress then outputs the matching lang attribute on your `<html>` tag automatically across the site.
What's the difference between "en" and "en-GB"?
`en` declares English in general, while `en-GB` specifies British English (and `en-US` American English). Plain `en` is fine for most sites; use the region form when spelling, currency or audience make the distinction meaningful.
How do I check if my page has a lang attribute?
Open the page, right-click and choose "View Page Source", and look at the first `<html>` tag. If it reads `<html lang="en">` (or your language) you're set; a bare `<html>` with no lang means it's missing.
Nasir Uddin
Nasir Uddin SEO & Growth Lead · ScoutRival

Nasir Uddin is an SEO consultant and ScoutRival's SEO & Growth Lead. He's spent years helping small businesses climb the search results — and now the AI answers too — and writes about SEO, AI-search visibility, and turning organic traffic into real growth.

Your unfair advantage

Stop reading about it. Ship it this week.

ScoutRival turns competitor intel into ready-to-post content and graphics — for a fraction of an agency.