Join early access

The page still says it is English

Translating every string does not change the language a page declares, and the browser and the screen reader act on the declaration rather than the text: it picks the hyphenation rules, the Turkish capital I, the quotation marks and the voice, while the usual accessibility audit only checks that the attribute is there.

An open violin case with its lid raised and a trumpet lying across the violin-shaped recess inside it, drawn in white line on a slate ground

A translated page can still say it is English

Start a new Next.js app with the official template and the root layout already contains one line about language: <html lang="en"> 1. Months later the product gets a French catalog. Every string is translated, reviewed and shipped. The root layout is not a string, so nobody translates it, and the page goes on declaring that it is English.

Nothing in the browser checks that claim against the text. The HTML standard decides an element’s language by walking up the tree: the element’s own lang attribute if it has one, otherwise its parent’s, and so on to the root, with a Content-Language pragma or header as the last fallback 2. A French paragraph with no attribute of its own inherits en from the root. As far as the browser is concerned, it is an English paragraph that happens to contain French words.

We have argued before that a locale identifier is a join key, and that formatting, collation and plural selection are lookups on it. Those are the lookups your code makes. This post is about the lookups the browser and the screen reader make, on a second copy of the key that your code has to keep in step by hand.

What the browser does with the declared language

The HTML standard lists what a browser may do with an element’s language: “the selection of appropriate fonts or pronunciations, for dictionary selection, or for the user interfaces of form controls such as date pickers” 2. CSS is more specific. “Language and writing system conventions can affect line breaking, hyphenation, justification, glyph selection, and many other typographic effects,” and those language-specific rules “are only applied when the content language is known (declared)” 3.

Known means declared. It does not mean detected. Each of the behaviours below reads the attribute, and none of them reads the text to see whether the attribute is true.

BehaviourSpecificationInput
Automatic hyphenationCSS Text 3, hyphens: autoA hyphenation resource for the content language, used only when that language is known
Uppercase and lowercaseCSS Text 3, text-transformLanguage-specific case rules such as Turkish i, applied only when the content language is known
Quotation marksCSS Generated Content 3, quotes: autoThe content language of the parent element
Line breaking in Chinese and JapaneseCSS Text 3, line-breakThe writing system implied by the declared language
Spell checkingHTML, spellcheckThe element's language, or the user's own language settings
Font and glyph choiceHTML, langThe element's language, among other inputs
What reads the declared language, per the specification that governs it.

Hyphenation shows why the wrong value is worse than none. The specification says the browser “must therefore only automatically hyphenate text for which the content language is known and for which it has an appropriate hyphenation resource” 3. Its own examples show that the rules are not just about where to break. Hungarian “Összeg” hyphenates as “Ösz-” and “szeg”, with a letter added, and Dutch “cafeetje” becomes “café-” and “tje”, with the spelling changed. Only a resource for that language knows to do that.

A wrong declaration is not an unknown one. Untagged text gets no language-specific treatment. Text tagged with the wrong language gets the wrong language’s treatment, because the browser has been told, with full confidence, which rules to apply.

Quotation marks follow the same logic. With quotes: auto, which is the initial value, “a typographically appropriate quotation mark system is automatically chosen by the UA based on the content language of the parent” 4. A <q> element in a translated French paragraph gets English marks if the paragraph says it is English. Spell checking is looser: the HTML standard says browsers “may use the language of the element to determine what spelling and grammar rules to use, or may use the user’s preferred language settings” 5. That is a may, so how much a wrong declaration costs in a form field depends on the browser.

One character, several regional shapes

The clearest case is Chinese, Japanese and Korean. W3C’s internationalization group puts it plainly: Simplified Chinese, Traditional Chinese, Japanese and Korean “may share the same code point for an ideographic character, but speakers of these languages expect the glyphs used to vary in small details from language to language,” and “in the absence of explicit styling applied by the content author, some browsers automatically assign appropriate fonts according to the language of the content” 6.

Unicode’s own FAQ gives an example. The “grass” radical, a component of thousands of characters, “appears as a four-stroke form (⺿) in Taiwan, Hong Kong SAR, and Macao SAR, but as a three-stroke form (⺾) in other regions.” It adds that “Japanese users prefer Japanese text written with ‘Japanese’ glyphs” 7. Some fonts carry several regional shapes for the same code point; the FAQ names Noto Sans CJK and Source Han Sans, which support five regional conventions. A font with five shapes still has to be told which one to draw.

Could the browser work it out from the text? The FAQ answers that question too. Asked how to tell whether a character is Chinese, Japanese or Korean, it replies: “It’s largely impossible and the attempt basically meaningless” 7. A page of kana is probably Japanese, but a short label made only of shared characters is not anything in particular. The declaration is the only signal the page sends. Exactly which shape a reader sees then depends on the browser, the operating system and the fonts installed, which is another reason to send the right signal rather than hope the defaults match.

What uppercase does depends on the language

Turkish has two letter i’s: a dotted one, “i” and “İ”, and a dotless one, “ı” and “I”. CSS Text applies language-specific case rules to text-transform “if (and only if) the content language of the element is, according to the rules of the document language, known.” It says the Turkish mapping “must only take effect if the content language is Turkish”, and states the other half just as firmly: “in other languages, the usual mapping of ‘I’ and ‘i’ is required” 3. The rule lives in Unicode’s SpecialCasing.txt as a conditional line: small i uppercases to U+0130, capital I with dot above, only under the language tag tr (and az) 8.

So a Turkish button styled text-transform: uppercase reads “İSTANBUL” under lang="tr" and “ISTANBUL” under lang="en". The translator wrote the right word. The stylesheet spelled it wrong.

JavaScript does not rescue this, because it does not read the page either. The plain methods ignore language, and the locale-aware ones take a language argument. Leave the argument out and the specification falls back to DefaultLocale(), the “host environment’s current locale”, which in a browser “should match navigator.language” 9. That is the language of the visitor’s browser, not the language of the page they are reading.

ts
01"istanbul".toUpperCase();             // "ISTANBUL"02"istanbul".toLocaleUpperCase("tr");   // "İSTANBUL"03"ISPARTA".toLocaleLowerCase("tr");    // "ısparta"04"istanbul".toLocaleUpperCase();       // the browser's language decides
Output from a JavaScript runtime. The Turkish rules apply only when Turkish is named, and the last line takes its language from the browser rather than from the page.

The screen reader picks its voice from the markup

For a sighted reader, most of the above is typography: wrong but legible. For someone using a screen reader, the declared language chooses the voice and the pronunciation rules, and the result can be unintelligible. WCAG’s explanation of the Language of Parts criterion gives the example: if a change of language is not marked, “the synthesizer will try its best to speak the words in the default language it works in. Thus, the French word for car, ‘voiture’ would be pronounced ‘voyture’ by a speech synthesizer that uses English as its default language” 10.

Now scale that from one word to a whole translated page. NVDA’s user guide describes its automatic language switching as switching “speech synthesizer languages automatically if the text being read specifies its language”, and adds that “this option is enabled by default” 11. The text specifies its language through the markup. A French page declared as English is read with English rules, by a screen reader that is behaving exactly as documented. WebAIM publishes a recording of the reverse mistake: an English passage read by a screen reader “as if it had lang="cs" (Czech)” 12.

The same applies inside a correctly declared page. A language picker lists each language in its own name, and WCAG’s worked example of Language of Parts is exactly such a list: links to Italiano, Français and 繁體中文, among others, with a lang attribute on each link 10. Without them, an English voice reads every entry, including the one in Chinese characters. One attribute on the root cannot describe a page that contains several languages; each part that differs needs its own.

A page keeps its language in three places

The declared language drifts because it is a separate copy. The catalog was picked from a route, a cookie or a header. The attribute was written into a layout. Whether the two are connected depends on the framework, and often on you.

Next.js shows both answers in its own documentation. The older Pages Router says: “Since Next.js knows what language the user is visiting it will automatically add the lang attribute to the <html> tag” 13. The App Router guide instead has you move the root layout under a [lang] segment and write <html lang={(await params).lang}> yourself 14. A team that started from the default template and added a catalog later has the template’s hard-coded line instead. The root layout is also where the catalog meets the client boundary, so it is the file a team is least eager to restructure.

Vue I18n’s lazy-loading guide is candid about whose job it is. Its example setI18nLanguage function switches the library’s locale and then, as a separate line of application code, calls document.querySelector('html').setAttribute('lang', locale) 15. The library changes the strings. Changing the declaration is the line you have to remember to write. i18next’s browser language detector goes the other way: the lang attribute is one of the places it reads a language from, listed in its default detection order after the browser’s own setting 16.

The formatter is a third copy. As the previous section showed, Intl and the locale-aware string methods default to the browser’s language, not the page’s 9. A page can therefore hold three languages at once, and nothing in the platform makes them agree.

ts
01// The catalog: chosen from the route, a cookie or Accept-Language02const messages = await getMessages(lang); // "tr"03​04// The document: written once, in the root layout05<html lang="en">06​07// The formatter: the browser's language, not the page's08new Intl.DateTimeFormat().format(date);09label.toLocaleUpperCase();
Three places one page keeps a language. Translating the catalog changes the first. The second is markup nobody translates, and the third reads neither.

This is the kind of debt we described in the second locale gets blamed for the first locale’s debt. A hard-coded en is invisible while the product only speaks English, and becomes wrong the day the second catalog ships.

An accessibility audit checks that the attribute exists

WCAG makes the page language a Level A requirement: “The default human language of each web page can be programmatically determined” 17. The automated checks most teams run test the first half of that sentence and stop.

The axe-core rules for language are worded precisely. html-has-lang: “Ensure every HTML document has a lang attribute.” html-lang-valid: “Ensure the lang attribute of the <html> element has a valid value.” valid-lang: “Ensure lang attributes have valid values.” The fourth checks that lang and xml:lang agree with each other 18. None of them looks at the text. Lighthouse weights its accessibility score using “axe user impact assessments” 19, and a French page that declares en passes every one of these rules, because en exists and is valid.

Even the presence check fails often. WebAIM’s 2026 crawl of the top million home pages found a missing document language on 13.5% of them, the sixth most common failure on the list 20. That figure counts pages with no declaration at all. A page that declares the wrong language is not in it.

A check that compares the two does exist. The W3C’s ACT rules include “HTML page language subtag matches default language”, which “checks that the primary language subtag of the page language matches the default language of the page” and works out that default language by “counting the number of words used in each language”. It is marked proposed, and its implementation list names Alfa, UsableNet AQA and Webmate, not axe 21,18. It also checks only the root element and only the primary subtag, so a correctly declared page with an unmarked language picker still passes. A green audit says the attribute is there and parses. It does not say the attribute is true.

The case that it barely matters

There is a serious argument that most of this is cosmetic, and part of it is right.

Search is one reason people give for setting the attribute, and Google says it does not read it: “Google uses the visible content of your page to determine its language. We don’t use any code-level language information such as lang attributes, or the URL” 22. The Next.js Pages Router documentation files its automatic lang attribute under “Search Engine Optimization” 13, the one consumer that has said it does not read it.

The best version of the counter-case comes from a developer who chose the wrong value on purpose. In August 2026, Ricardo Diaz Miralles described a Next.js App Router site where reading the locale in the root layout made every route render on demand. Hard-coding lang="en" took it from 1 static route and 76 dynamic ones to 77 static and none, and roughly halved the time to first byte. “The root layout now serves lang="en" in the static HTML for every route, including the Spanish ones, and the provider corrects it on hydration.” The proper fix, separate root layouts, meant relocating around sixty route directories, and the author declined to do that for “an attribute that Google has repeatedly said it ignores for language detection” 23.

Add the softer limits. WebAIM notes that region subtags “are typically ignored, especially if the screen reader’s default language matches the primary language specified” 12, and NVDA ships dialect switching turned off 11, so en-US against en-GB rarely matters. The automatic font assignment W3C describes happens only “in the absence of explicit styling” 6. A Latin-script product with its own fonts, no automatic hyphenation and no uppercase styling loses very little to a wrong attribute on a sighted reader’s screen.

What the counter-case does not cover is the rest of the list: the voice a screen reader uses, Han glyph shapes, Turkish casing, quotation marks, the language picker. And look at what the careful version actually did. The same post says “accessibility was the real concern,” adds a small layout that sets document.documentElement.lang="es" for the Spanish pages, and calls the whole arrangement “a compromise, not a best practice” 23. The author did not conclude that the attribute is unimportant. They concluded that it is a separate copy of the locale, and wrote a separate code path to keep it right.

How to keep the declaration honest

A translated string can be linguistically perfect and still broken by what surrounds it. The declared language is the simplest example: a fact about the text that lives outside the text, where no reviewer reads it. Treat it as data your build produces, not as markup someone types once.

  1. Derive the root lang from the same value that chose the catalog, and write it into the server-rendered HTML. A script that corrects it after load is better than nothing and worse than getting it right in the first response.
  2. Mark the parts that differ: the language picker, a quoted title, a customer name in another script, user-generated content whose language you know. One attribute on the root describes one language.
  3. Pass the locale to Intl and to toLocaleUpperCase explicitly. Their default is the visitor’s browser, not your page.
  4. Use the shortest tag that is true. A primary language subtag is what screen readers act on most reliably; add a region or script only when the difference matters to the reader 12.
  5. Test the declaration, not only its existence: render each locale and assert that document.documentElement.lang matches the catalog that was served. If you run a pseudo-locale, make it check this too. A content-matching rule such as ACT ucwvc8 catches the root; only a person with a screen reader catches the rest 21.

A violin case with a trumpet in it is still a violin case to anyone who has not opened it. The browser and the screen reader do not open it. They read the label on the outside and act on that.

References

  1. 1.Vercel create-next-app App Router template, app/layout.tsx vercel/next.js on GitHub
  2. 2.WHATWG The lang and xml:lang attributes HTML Living Standard
  3. 3.W3C CSS Text Module Level 3 W3C Candidate Recommendation Draft, 14 August 2026
  4. 4.W3C CSS Generated Content Module Level 3 W3C Working Draft, 4 December 2025
  5. 5.WHATWG Spelling and grammar checking HTML Living Standard
  6. 6.W3C Internationalization Why use the language attribute? W3C
  7. 7.Unicode FAQ: Chinese and Japanese unicode.org
  8. 8.Unicode SpecialCasing.txt Unicode Character Database 18.0.0
  9. 9.Ecma TC39 ECMAScript Internationalization API Specification ECMA-402, 2027 draft
  10. 10.W3C WAI Understanding Success Criterion 3.1.2: Language of Parts WCAG 2.2
  11. 11.NV Access NVDA 2026.3.1 User Guide nvaccess.org
  12. 12.WebAIM Document and Content Language webaim.org
  13. 13.Vercel How to implement internationalization in Next.js (Pages Router) Next.js documentation
  14. 14.Vercel Internationalization (App Router) Next.js documentation
  15. 15.Intlify Lazy loading Vue I18n guide
  16. 16.i18next i18next-browser-languageDetector README on GitHub
  17. 17.W3C WAI Understanding Success Criterion 3.1.1: Language of Page WCAG 2.2
  18. 18.Deque Systems axe-core rule descriptions dequelabs/axe-core on GitHub
  19. 19.Chrome for Developers Lighthouse accessibility score developer.chrome.com
  20. 20.WebAIM The WebAIM Million: The 2026 report on the accessibility of the top 1,000,000 home pages webaim.org
  21. 21.ACT Rules Community Group HTML page language subtag matches default language W3C ACT rule ucwvc8, proposed
  22. 22.Google Search Central Managing multi-regional and multilingual sites developers.google.com
  23. 23.Ricardo Diaz Miralles, 2026 One line in your root layout can make every Next.js page render on demand DEV Community