BCP 47 language tag reference
A BCP 47 language tag identifies a human language together with optional script, region, variant and extension information. It is the value used in HTML lang attributes, hreflang, HTTP Accept-Language, and locale APIs. Tags are built by joining registered subtags with hyphens, drawing on ISO 639 (language), ISO 15924 (script), ISO 3166-1 / UN M.49 (region) and the IANA Language Subtag Registry.
How it works
A well-formed tag follows a fixed order, each part optional except the primary language:
language - Script - REGION - variant - extension - privateuse
en Latn US 1996 u-ca-... x-foo
Casing is conventional but recommended: language subtags are lowercase (en), script subtags are Title-case 4 letters (Latn), region subtags are UPPERCASE 2 letters or 3 digits (GB, 419), and variants are lowercase. A subtag’s class is determined by its shape: 2-3 letters at the front is the language, exactly 4 letters is a script, 2 letters or 3 digits after that is a region, and 5-8 alphanumerics (or 4 starting with a digit) is a variant.
Extensions begin with a single-letter singleton: u for Unicode locale keywords (calendar, numbering, collation), t for transformed content, and x for private use (everything after x- is opaque). Matching uses these subtags hierarchically — en-GB falls back to en when no exact match exists.
Where BCP 47 tags appear in practice
HTML lang attribute — the most common use. <html lang="en-GB"> tells browsers, screen readers, and spell-checkers which language and locale to apply. Setting only the primary language (lang="en") is usually correct; add the region subtag when British vs. American spelling or date formats matter to your audience.
hreflang links — used in <link rel="alternate" hreflang="fr-CH" href="..."> to tell search engines about alternate-language versions of a page. x-default is a special pseudo-tag for the fallback page. Using zh-Hans vs zh-Hant here correctly targets simplified vs traditional Chinese audiences regardless of their country.
HTTP Accept-Language — browsers send a ranked list of BCP 47 tags in this header. Servers use it for content negotiation: Accept-Language: en-GB,en;q=0.9,fr;q=0.8 prefers British English, then any English, then French.
Intl JavaScript APIs — Intl.NumberFormat, Intl.DateTimeFormat, and Intl.Collator all accept BCP 47 tags. The u extension is especially useful here: en-US-u-nu-fullwide selects full-width digit characters, and en-US-u-ca-hebrew requests the Hebrew calendar.
ICU and CLDR — many formatting libraries (Java’s Locale, .NET’s CultureInfo, Python’s babel) ultimately trace back to BCP 47 under the hood.
Common tags and their correct form
| Purpose | Tag | Notes |
|---|---|---|
| US English | en-US | Most common default for English-language apps |
| British English | en-GB | Date format, spelling and vocabulary variant |
| Simplified Chinese | zh-Hans | Script subtag preferred over zh-CN for portability |
| Traditional Chinese | zh-Hant | Covers Taiwan, Hong Kong, and overseas communities |
| Latin American Spanish | es-419 | UN M.49 region code for Latin America |
| Brazilian Portuguese | pt-BR | Distinct from European Portuguese (pt-PT) |
| Modern Standard Arabic | ar | Script (Arabic) is implied; no subtag needed |
| Serbian (Cyrillic) | sr-Cyrl | Serbia uses both scripts; specify when it matters |
| Serbian (Latin) | sr-Latn | Used in Bosnia and some Croatian-influenced contexts |
| German (1996 orthography) | de-1996 | Variant subtag for post-reform German spelling |
Tips and examples
- Do not over-specify.
enis usually better thanen-Latn-US-x-mineunless each subtag is genuinely needed; redundant scripts hurt content negotiation. - For Chinese, choose script over region for written content:
zh-Hans(simplified) andzh-Hant(traditional) are more portable thanzh-CN/zh-TW. - Use the UN M.49 numeric region
419for “Latin America” when no single country applies, e.g.es-419. - Validate tags against the IANA Language Subtag Registry; only registered subtags are well-formed, with
x-private use as the escape hatch for unregistered values.