Language and Region Codes: en-US, en-GB, zh-Hans
Language codes identify the language of content (en, de, zh), and region codes identify a country or territory (US, GB, CH). In hreflang and HTML they are joined into one tag with the language first and the optional region second: en-GB, de-CH. A tag cannot be a region alone, and en-UK is wrong; the United Kingdom is GB.
What are language codes and region codes?
Three standards sit behind most of the tags you see on the web:
| Part | Standard | Format | Examples |
|---|---|---|---|
| Language | ISO 639-1 (two letters) | lowercase | en, fr, de, ja |
| Script (optional) | ISO 15924 | four letters, title case | Hans, Hant, Latn, Cyrl |
| Region (optional) | ISO 3166-1 alpha-2 (two letters) or UN M.49 (three digits) | uppercase | US, GB, CH, 419 |
Google's hreflang documentation says values are a language in ISO 639-1 format, optionally combined with a region in ISO 3166-1 alpha-2 format, and that script codes (ISO 15924) such as zh-Hant and zh-Hans are accepted too.
What is BCP 47?
BCP 47 is the IETF specification that defines how these parts combine into a language tag. Its current core text is RFC 5646. It is the format used by the HTML lang attribute, according to MDN, and the hreflang values Google documents are a subset of it.
Key rules from RFC 5646:
- A tag is a series of hyphen-separated subtags in a fixed order: language, optional script, optional region, then less common parts.
- Use the two-letter ISO 639-1 code when one exists. Only languages without one use a three-letter code.
- Tags are case-insensitive, but the recommended convention is lowercase language, title-case script and uppercase region:
zh-Hant-TW. - Omit the script when it adds nothing. The registry's Suppress-Script field records the usual script for a language, so
en-Latnis redundant. - Omit the region when it adds nothing.
W3C's guidance on choosing language tags puts it as "the golden rule is to keep your language tag as short as possible". The authoritative list of valid subtags is the IANA Language Subtag Registry, which both W3C and RFC 5646 point to.
Should I use en, en-US or en-GB?
Use the shortest tag that describes what you actually publish.
- One English version for everyone:
en. - Different regional editions:
en-US,en-GB,en-AUand so on, each with its own URL and content differences (spelling, currency, shipping, legal). Google's hreflang page explicitly lists small regional variations in a single language as a use case. - A regional version plus a general fallback: you can publish both
enanden-GB. A fuller treatment of fallback behaviour is in the hreflang guide.
Do not create regional versions that are identical copies. If en-US and en-GB differ only by tag, you have added maintenance and no value. W3C's page makes a related point: the region in ja-JP is unlikely to be useful in most cases, while en-GB can be, for example, for spell-checking.
<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" />
<link rel="alternate" hreflang="de-CH" href="https://example.com/ch/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
How do I handle Chinese: zh-Hans, zh-Hant, zh-CN, zh-TW?
Chinese varies by writing system as well as by place. Three approaches appear in Google's examples:
- By script:
zh-Hans(Simplified) andzh-Hant(Traditional). Use this when your content differs by script and not by market. - By region:
zh-CN(mainland China) orzh-TW(Taiwan). Use this when you target a specific market and its vocabulary. - Both:
zh-Hant-TWor similar combinations are allowed; Google's page shows script-plus-region examples such aszh-Hans-US.
Pick one scheme and use it across all pages. Mixing zh-CN on some pages and zh-Hans on others for the same content creates confusing sets. Also note that zh alone is conventionally associated with Mandarin, per W3C; W3C warns that using cmn for this purpose may cause serious compatibility problems.
What are the most common code mistakes?
Google's page identifies several. The first three below are documented; the rest are common practice or our inference.
- Region-only codes. The first part must be a language. Google's example is
be, which is Belarusian, not Belgium. For Belgium use a language plus region, such asnl-BEorfr-BE. en-UK. Google saysUKis a reserved code that has no effect; useen-GB.EUandUNare ignored too.- Unsupported codes. Google lists
es-419(Latin American Spanish) as not supported in hreflang, even though it is a valid BCP 47 tag. In hreflang, useesor specific countries such ases-MX. It remains valid for the HTMLlangattribute. - Underscores. Use
en-GB, noten_GB. Underscore forms come from operating system locale names, not web standards. - Three-letter codes where a two-letter one exists, such as
enginstead ofen. - Using a language code as a country code, such as
jpfor Japan (the language isja; the country isJP) orzhfor China. - Inconsistent codes between hreflang, sitemap, and
langfor the same page. See common hreflang mistakes.
What is the difference between the HTML lang attribute and hreflang?
They do different jobs and are often confused.
| Item | lang attribute |
hreflang annotation |
|---|---|---|
| Where | On <html> or any element |
On <link>, in an HTTP header or in a sitemap |
| Purpose | Declares the language of this content | Tells search engines which URLs are alternates for which audience |
| Format | BCP 47 | Language, optional script, optional region |
| Used by | Browsers, screen readers, translation tools, spell-checkers | Search engines that support it (Google documents it) |
| Google detects language from it? | No | No |
Google states that it does not use hreflang or the HTML lang attribute to detect page language; it uses its own algorithms. That does not make lang optional. MDN notes that WCAG 3.1.1 requires the page language to be programmatically determinable, mainly so assistive technology can choose the right pronunciation, and WCAG 3.1.2 covers passages in a different language. Treat them as two correct declarations that should agree.
<html lang="de-CH">
<head>
<link rel="alternate" hreflang="de-CH" href="https://example.com/ch/" />
</head>
W3C's language declaration guidance recommends putting lang on the html element rather than body, and advises against using a meta Content-Language element to declare the page language. An empty lang="" means the language is unknown, according to MDN.
How do I audit the codes on my site?
- List every tag in use across
lang, hreflang tags and sitemap entries. - Check each against the rules above: language first, valid case, no region-only values.
- Confirm the same tag is used for the same page in every location.
- Check the codes in the multilingual SEO checklist before and after launch.
Key takeaways
- A tag is language first, then optional script, then optional region:
zh-Hant-TW,en-GB. - Use ISO 639-1 language codes and ISO 3166-1 alpha-2 region codes; use
GB, notUK. - Keep tags as short as possible; add a region only for genuinely different regional content.
- Google ignores
langfor language detection but you should still set it for accessibility and tooling. - Region-only codes and unsupported values such as
es-419in hreflang are silently ineffective.
Sources
- Localized versions of your pages – hreflang code format, region-only and UK/EU handling, lang attribute note
- RFC 5646: Tags for Identifying Languages – BCP 47 structure, case conventions, shortest-code rule
- Choosing a language tag (W3C) – keep tags short, when to add script or region
- Declaring language in HTML (W3C) – lang on html, BCP 47, Content-Language caution
- lang global attribute (MDN) – BCP 47 values, unknown and invalid states, WCAG 3.1.1
Frequently asked questions
What is the correct hreflang code for the United Kingdom?
Use en-GB. The ISO 3166-1 region code for the United Kingdom is GB, and Google's documentation says that UK has no effect in hreflang. Also remember the language comes first: the code is language plus optional region, so en-GB means English as used in Great Britain, not just the UK as a place.
Should I use en or en-US?
Use en when one English version serves all English speakers. Use en-US, en-GB and so on only when you publish genuinely different versions for those regions, such as different spelling, prices or legal text. W3C advises keeping language tags as short as possible and adding subtags only when they distinguish something useful.
What is the difference between zh-Hans and zh-Hant?
They identify the writing system: zh-Hans is Chinese in Simplified script and zh-Hant is Chinese in Traditional script. They are script subtags from ISO 15924. Google accepts them in hreflang, and you can add a region, as in zh-Hant-TW or zh-TW, when you also target a specific place.
Does Google use the HTML lang attribute?
Google's documentation says it does not use hreflang or the lang attribute to detect the language of a page, relying on its own algorithms. You should still set lang correctly, because browsers, translation tools and screen readers use it, and WCAG requires the page language to be programmatically determinable.