The lang attribute on the <html> element tells browsers and assistive technologies what language the page content is in. Screen readers use this to load the correct pronunciation rules, speech patterns, and voice.
Without a language declaration, screen readers have to guess the page language based on user settings. If they guess wrong, content becomes incomprehensible. A French page read with English pronunciation rules produces nonsensical audio. Even for English pages, missing the lang attribute affects hyphenation, quotes, and other language-specific features.
Check if lang attribute exists with a valid value.
Quick console check:
const lang = document.documentElement.lang
if (!lang) {
console.error('HTML element is missing lang attribute')
}
else {
console.log('Page language:', lang)
}
<!-- Basic language codes -->
<html lang="en"> <!-- English -->
<html lang="es"> <!-- Spanish -->
<html lang="fr"> <!-- French -->
<html lang="de"> <!-- German -->
<html lang="ja"> <!-- Japanese -->
<html lang="zh"> <!-- Chinese -->
<!-- With regional variants -->
<html lang="en-US"> <!-- American English -->
<html lang="en-GB"> <!-- British English -->
<html lang="pt-BR"> <!-- Brazilian Portuguese -->
<html lang="zh-Hans"> <!-- Simplified Chinese -->
<html lang="zh-Hant"> <!-- Traditional Chinese -->
When content switches language within the page, use lang on specific elements:
<html lang="en">
<body>
<p>The French phrase <span lang="fr">c'est la vie</span> means "that's life".</p>
<blockquote lang="de">
Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt.
</blockquote>
<p>— Ludwig Wittgenstein</p>
</body>
</html>
Screen readers will switch pronunciation rules for the marked sections.
While lang attributes are a lightweight signal for SEO geo-targeting, their biggest impact is on User Friction.
If you omit the lang attribute (or set it wrong), browsers like Chrome incorrectly detect the page language. This triggers the "Translate this page?" popup for every user.
The friction: Users have to dismiss a popup before interacting with your site.
The result: Increased bounce rate and lower time-on-page, which are negative signals for search engines.
Geo-targeting: For international SEO, the html lang attribute works in tandem with hreflang tags to make sure the right regional version of your site is served to the right user.
Missing lang attributes often occur in error pages, legacy templates, or dynamically generated pages that bypass your main layout. Unlighthouse scans every page on your site and flags any missing lang attributes, so you have consistent accessibility across all routes.
\n",[4303,5438,5439],{"class":4364,"line":4479},[4303,5440,5441],{}," \n",[4303,5443,5444],{"class":4364,"line":4626},[4303,5445,5446],{}," \n",[4303,5448,5449],{"class":4364,"line":4635},[4303,5450,5451],{}," \n",[4303,5453,5454],{"class":4364,"line":4812},[4303,5455,5456],{}," \n",[4303,5458,5459],{"class":4364,"line":4835},[4303,5460,5348],{},[4303,5462,5463],{"class":4364,"line":4858},[4303,5464,4442],{},[4286,5466,5468],{"id":5467},"user-experience-bounce-rate","User experience & bounce rate",[4282,5470,5471,5472,5474,5475,4383],{},"While ",[4294,5473,4296],{}," attributes are a lightweight signal for SEO geo-targeting, their biggest impact is on ",[5096,5476,5477],{},"User Friction",[4282,5479,5480,5481,5483],{},"If you omit the ",[4294,5482,4296],{}," attribute (or set it wrong), browsers like Chrome incorrectly detect the page language. This triggers the \"Translate this page?\" popup for every user.",[5485,5486,5487,5493,5499],"ul",{},[4330,5488,5489,5492],{},[5096,5490,5491],{},"The friction",": Users have to dismiss a popup before interacting with your site.",[4330,5494,5495,5498],{},[5096,5496,5497],{},"The result",": Increased bounce rate and lower time-on-page, which are negative signals for search engines.",[4330,5500,5501,5504,5505,5508,5509,5511],{},[5096,5502,5503],{},"Geo-targeting",": For international SEO, the ",[4294,5506,5507],{},"html lang"," attribute works in tandem with ",[4294,5510,4151],{}," tags to make sure the right regional version of your site is served to the right user.",[4286,5513,5515],{"id":5514},"verify-the-fix","Verify the fix",[4327,5517,5518,5537],{},[4330,5519,5520,5523,5524,5532,5533,5536],{},[5096,5521,5522],{},"Re-run Lighthouse"," - The \"",[4294,5525,5526,5528,5530],{"className":4300,"language":4301,"style":1843},[4303,5527,4306],{"class":4305},[4303,5529,4301],{"class":4309},[4303,5531,4312],{"class":4305}," element has a ",[4294,5534,5535],{},"[lang]"," attribute\" audit should pass.",[4330,5538,5539,4656],{},[5096,5540,5541],{},"Console verification",[4355,5543,5545],{"className":4357,"code":5544,"language":4359,"meta":1843,"style":1843},"const lang = document.documentElement.lang\nconsole.log('Lang attribute:', lang || 'MISSING')\nconsole.log('Valid:', /^[a-z]{2,3}(?:-[A-Za-z]{2,4})?$/.test(lang))\n",[4294,5546,5547,5565,5600],{"__ignoreMap":1843},[4303,5548,5549,5551,5553,5555,5557,5559,5561,5563],{"class":4364,"line":1766},[4303,5550,4368],{"class":4367},[4303,5552,4372],{"class":4371},[4303,5554,4376],{"class":4375},[4303,5556,4380],{"class":4379},[4303,5558,4383],{"class":4305},[4303,5560,4386],{"class":4379},[4303,5562,4383],{"class":4305},[4303,5564,4391],{"class":4379},[4303,5566,5567,5570,5572,5574,5576,5578,5581,5583,5585,5588,5591,5593,5596,5598],{"class":4364,"line":1756},[4303,5568,5569],{"class":4379},"console",[4303,5571,4383],{"class":4305},[4303,5573,4460],{"class":4419},[4303,5575,4424],{"class":4379},[4303,5577,4428],{"class":4427},[4303,5579,5580],{"class":4431},"Lang attribute:",[4303,5582,4428],{"class":4427},[4303,5584,4472],{"class":4305},[4303,5586,5587],{"class":4379}," lang ",[4303,5589,5590],{"class":4375},"||",[4303,5592,5162],{"class":4427},[4303,5594,5595],{"class":4431},"MISSING",[4303,5597,4428],{"class":4427},[4303,5599,4437],{"class":4379},[4303,5601,5602,5604,5606,5608,5610,5612,5615,5617,5619,5622,5625,5629,5633,5636,5639,5642,5645,5647,5650,5652,5655,5658,5661,5664,5667,5669,5672],{"class":4364,"line":1828},[4303,5603,5569],{"class":4379},[4303,5605,4383],{"class":4305},[4303,5607,4460],{"class":4419},[4303,5609,4424],{"class":4379},[4303,5611,4428],{"class":4427},[4303,5613,5614],{"class":4431},"Valid:",[4303,5616,4428],{"class":4427},[4303,5618,4472],{"class":4305},[4303,5620,5621],{"class":4427}," /",[4303,5623,5624],{"class":4396},"^",[4303,5626,5628],{"class":5627},"swiL2","[",[4303,5630,5632],{"class":5631},"sJFDI","a-z",[4303,5634,5635],{"class":5627},"]",[4303,5637,5638],{"class":4375},"{2,3}",[4303,5640,5641],{"class":4427},"(?:",[4303,5643,5644],{"class":4431},"-",[4303,5646,5628],{"class":5627},[4303,5648,5649],{"class":5631},"A-Za-z",[4303,5651,5635],{"class":5627},[4303,5653,5654],{"class":4375},"{2,4}",[4303,5656,5657],{"class":4427},")",[4303,5659,5660],{"class":4375},"?",[4303,5662,5663],{"class":4396},"$",[4303,5665,5666],{"class":4427},"/",[4303,5668,4383],{"class":4305},[4303,5670,5671],{"class":4419},"test",[4303,5673,5674],{"class":4379},"(lang))\n",[4327,5676,5677],{},[4330,5678,5679,5682],{},[5096,5680,5681],{},"Screen reader test"," - The page should be read with correct pronunciation for the declared language.",[4286,5684,5686],{"id":5685},"common-mistakes","Common mistakes",[5485,5688,5689,5713,5741,5762,5772],{},[4330,5690,5691,5694,5695,5703,5704,5712],{},[5096,5692,5693],{},"Lang on body instead of HTML",": Must be on ",[4294,5696,5697,5699,5701],{"className":4300,"language":4301,"style":1843},[4303,5698,4306],{"class":4305},[4303,5700,4301],{"class":4309},[4303,5702,4312],{"class":4305},", not ",[4294,5705,5706,5708,5710],{"className":4300,"language":4301,"style":1843},[4303,5707,4306],{"class":4305},[4303,5709,4617],{"class":4309},[4303,5711,4312],{"class":4305},". The lang attribute on body is ignored by most tools.",[4330,5714,5715,5718,5719,5738,5739,4383],{},[5096,5716,5717],{},"Invalid language code",": ",[4294,5720,5721,5723,5725,5727,5729,5731,5734,5736],{"className":4300,"language":4301,"style":1843},[4303,5722,4306],{"class":4305},[4303,5724,4301],{"class":4309},[4303,5726,4372],{"class":4504},[4303,5728,4519],{"class":4305},[4303,5730,4522],{"class":4427},[4303,5732,5733],{"class":4431},"english",[4303,5735,4522],{"class":4427},[4303,5737,4312],{"class":4305}," is invalid. Use proper BCP 47 codes like ",[4294,5740,4583],{},[4330,5742,5743,5718,5746,5761],{},[5096,5744,5745],{},"Empty lang attribute",[4294,5747,5748,5750,5752,5754,5756,5759],{"className":4300,"language":4301,"style":1843},[4303,5749,4306],{"class":4305},[4303,5751,4301],{"class":4309},[4303,5753,4372],{"class":4504},[4303,5755,4519],{"class":4305},[4303,5757,5758],{"class":4427},"\"\"",[4303,5760,4312],{"class":4305}," fails the audit. Must contain a valid code.",[4330,5763,5764,5767,5768,5771],{},[5096,5765,5766],{},"Wrong language",": Setting ",[4294,5769,5770],{},"lang=\"en\""," on a French page is worse than no lang at all. Screen readers will mispronounce everything.",[4330,5773,5774,5777,5778,5780,5781,5783,5784,5780,5787,4383],{},[5096,5775,5776],{},"Regional variants",": For content with regional spelling or vocabulary differences, use ",[4294,5779,4825],{}," vs ",[4294,5782,4848],{},", ",[4294,5785,5786],{},"pt-PT",[4294,5788,4871],{},[4286,5790,5792],{"id":5791},"related-issues","Related issues",[4282,5794,5795],{},"HTML lang issues often appear alongside:",[5485,5797,5798,5803,5809],{},[4330,5799,5800,5802],{},[4650,5801,4131],{"href":4130}," - Both are document-level requirements set in the head",[4330,5804,5805,5808],{},[4650,5806,5807],{"href":4136},"Heading order"," - Proper lang makes sure headings are pronounced correctly",[4330,5810,5811,5814],{},[4650,5812,5813],{"href":4150},"Hreflang"," - Multi-language sites need both HTML lang and hreflang",[4286,5816,5818],{"id":5817},"test-your-entire-site","Test your entire site",[4282,5820,5821],{},"Missing lang attributes often occur in error pages, legacy templates, or dynamically generated pages that bypass your main layout. Unlighthouse scans every page on your site and flags any missing lang attributes, so you have consistent accessibility across all routes.",[5823,5824,5825],"style",{},"html pre.shiki code .sx-uw, html code.shiki .sx-uw{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#89DDFF}html pre.shiki code .sV-QU, html code.shiki .sV-QU{--shiki-light:#22863A;--shiki-default:#22863A;--shiki-dark:#F07178}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .swqme, html code.shiki .swqme{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#C792EA}html pre.shiki code .smpaK, html code.shiki .smpaK{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#BABED8}html pre.shiki code .sc1V3, html code.shiki .sc1V3{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#89DDFF}html pre.shiki code .sqjlB, html code.shiki .sqjlB{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#BABED8}html pre.shiki code .smL2f, html code.shiki .smL2f{--shiki-light:#D73A49;--shiki-light-font-style:inherit;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s0YkB, html code.shiki .s0YkB{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#82AAFF}html pre.shiki code .sqVJQ, html code.shiki .sqVJQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#F07178}html pre.shiki code .sbw7o, html code.shiki .sbw7o{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#89DDFF}html pre.shiki code .sJnJ8, html code.shiki .sJnJ8{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#C3E88D}html pre.shiki code .sg-iE, html code.shiki .sg-iE{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#C792EA}html pre.shiki code .sTBSN, html code.shiki .sTBSN{--shiki-light:#6A737D;--shiki-light-font-style:inherit;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .swiL2, html code.shiki .swiL2{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#89DDFF}html pre.shiki code .sJFDI, html code.shiki .sJFDI{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#C3E88D}",{"title":1843,"searchDepth":1756,"depth":1756,"links":5827},[5828,5829,5833,5838,5839,5840,5841,5842,5843],{"id":4288,"depth":1756,"text":4289},{"id":4319,"depth":1756,"text":4320,"children":5830},[5831,5832],{"id":4324,"depth":1828,"text":4325},{"id":4484,"depth":1828,"text":4485},{"id":4532,"depth":1756,"text":4533,"children":5834},[5835,5836,5837],{"id":4536,"depth":1828,"text":4537},{"id":4644,"depth":1828,"text":4645},{"id":4927,"depth":1828,"text":4928},{"id":5087,"depth":1756,"text":5088},{"id":5467,"depth":1756,"text":5468},{"id":5514,"depth":1756,"text":5515},{"id":5685,"depth":1756,"text":5686},{"id":5791,"depth":1756,"text":5792},{"id":5817,"depth":1756,"text":5818},"Learn how to fix missing lang attribute in Lighthouse accessibility audits. The lang attribute helps screen readers pronounce content correctly.","md","i-heroicons-wrench-screwdriver",[5848,5849,5850,5851,5852],"html-has-lang","lang attribute","language","accessibility","screen reader",{"tags":5854},[5851,5855],"lighthouse",{"title":4095},null,"4 min",[5860,5863],{"path":5861,"title":5862},"/learn-lighthouse/accessibility#common-accessibility-issues","All Accessibility Issues",{"path":4086,"title":5864},"Accessibility Overview",{"title":4277,"description":5844},{"loc":4094,"lastmod":313},"learn-lighthouse/accessibility/10.html-has-lang","1rS29wPvEdgpW5bS6LFDZ9k4FfbvOZ3660dvX-1006M",[5870,5873],{"title":4092,"path":4091,"stem":5871,"description":5872,"children":-1,"_path":4091},"learn-lighthouse/accessibility/1.aria-hidden-focus","Learn how to fix aria-hidden-focus issues in Lighthouse accessibility audits",{"title":4098,"path":4097,"stem":5874,"description":5875,"children":-1,"_path":4097},"learn-lighthouse/accessibility/11.image-alt","Learn how to fix missing image alt attributes in Lighthouse accessibility audits",["Reactive",5877],{"$scolor-mode":5878,"$snuxt-seo-utils:routeRules":5880,"$stoasts":5881,"$snuxt-seo:breadcrumb:breadcrumb":5882,"$ssite-config":5889},{"preference":5879,"value":5879,"unknown":4803,"forced":3855},"system",{"head":-1,"seoMeta":-1},[],[5883,5887,5888],{"to":5884,"icon":5885,"label":5886,"ariaLabel":5886,"current":3855},"/learn-lighthouse","i-heroicons-academic-cap","Learn Google Lighthouse",{"to":4086,"label":4081,"ariaLabel":4081,"current":3855},{"to":4086,"label":4087,"ariaLabel":4087,"current":3855},{"_priority":5890,"description":5893,"env":5894,"name":5895,"titleSeparator":5896,"url":5897},{"env":5891,"url":5892,"name":5892,"description":5892,"titleSeparator":5892},-15,-3,"Google Lighthouse for your entire site.","production","Unlighthouse","·","https://unlighthouse.dev",["Set"],["ShallowReactive",5900],{"stats":-1,"search":-1,"navigation":-1,"learn-nav":-1,"learn-/learn-lighthouse/accessibility/html-has-lang":-1,"learn-/learn-lighthouse/accessibility/html-has-lang-surround":-1}]