murattunalı.

Language tag.

BCP 47DEFINITION

A language tag is the standard coding form that tells machines which language a text is in.

Used on the root element it declares the page’s main language; used on a section it declares that section’s language. Screen readers choose the speech engine from that declaration; if it is missing or wrong, the text is spoken in the wrong language.

The form consists of a language code and an optional region code. Two-letter standard codes are used for the language and two-letter country codes for the region. The separator is a hyphen; the underscore belongs to a different standard’s form.

A region code is only meaningful if the pronunciation genuinely differs — as with the American and British variants of English. For Turkish the two-letter language code is enough.

  1. On the root element — on every page, without exception. Required at WCAG level A.
  2. At section level — quotations and labels in a foreign language.
  3. Language switcher labels — each in its own language and with that language declared.
  4. Brand names — usually not marked; their pronunciation is recognised.
  5. Code fragments — marked as code, not as a language.

The declaration concerns more than the screen reader: the browser’s translation offer, its spell checking and its typographic rules are all fed by it. A one-line declaration makes four systems work correctly at once.

Its use on the root element is required at WCAG level A, a baseline requirement. Its use at section level sits at level AA and covers quotations in a foreign language.

On multilingual sites the section level is needed especially often: the labels in a language switcher are written in their own languages and their languages have to be declared. The word “Deutsch” read out by a Turkish speech engine becomes unintelligible.

It belongs to the same family as the value in hreflang but is not identical: here the region code is usually unnecessary. If the pronunciation does not genuinely differ, the two-letter language code is enough and safer.

  1. On the root element — on every page, without exception. WCAG level A.
  2. At section level — foreign-language quotations and language switcher labels.
  3. Region code — only if the pronunciation genuinely differs.
  4. The separator is a hyphen — the underscore belongs to a different standard.
  5. Code fragments — marked as code, not as a language.

A note on scope: the declaration concerns more than the screen reader. The browser’s translation offer, its spell checking and its typographic rules are all fed by it — a one-line declaration makes four systems work correctly at once.

SOURCES