W3docs

HTML Language Codes

How HTML language codes work: the lang attribute, BCP 47 tags with region and script subtags, why they matter, and a full ISO 639-1 code list.

HTML Language Codes

This page explains the language codes you use with the HTML lang attribute (and the related hreflang attribute): what standard they come from, how to combine a language with a region or script, and where to find the code for a given language.

What standard do lang values actually use?

The value of lang is not a bare ISO code — it is a BCP 47 language tag. A BCP 47 tag is built from subtags in a fixed order:

language[-script][-region]
  • language — a two-letter ISO 639-1 code such as en, fr, zh. When a language has no 639-1 code, the three-letter ISO 639-2/639-3 code is used instead.
  • script — an optional four-letter ISO 15924 code such as Hans (Simplified Han) or Hant (Traditional Han).
  • region — an optional two-letter ISO 3166-1 country code such as US, BR, GB.

So en is a valid tag, and so are en-US, pt-BR, and zh-Hans. The language subtag is written lowercase, the script is title-case, and the region is uppercase — but tags are matched case-insensitively.

Why declaring the language matters

Setting lang correctly does real work, not just documentation:

  • Screen readers pick the right text-to-speech voice and pronunciation rules from lang. The same letters are read very differently in English versus French, so a wrong or missing lang produces garbled speech.
  • Right-to-left languages still need the dir attribute (dir="rtl") — lang="ar" alone does not flip text direction.
  • Search engines use the language (and hreflang on alternate-language pages) to serve the right version of your site to the right audience.
  • Browsers use it for spell-checking, choosing the correct font/typography, and applying language-specific CSS such as :lang() and hyphenation.

Declaring the page language

The W3C recommends declaring the primary language of every page with a lang attribute on the root <html> tag:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>My page</title>
  </head>
  <body>
    ...
  </body>
</html>

In XHTML you set both lang and xml:lang:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...
</html>

Adding a region or script subtag

Use a region or script subtag when the variant matters — for spelling, pronunciation, or which written form to show:

<!-- Brazilian Portuguese, distinct from European Portuguese (pt-PT) -->
<html lang="pt-BR">

<!-- Plain Portuguese, no region preference -->
<html lang="pt">

<!-- Chinese written in Simplified characters -->
<html lang="zh-Hans">

<!-- Chinese written in Traditional characters, as used in Taiwan -->
<html lang="zh-Hant-TW">

Prefer the shortest tag that conveys the needed distinction: use plain en unless British vs. American spelling actually matters, in which case use en-GB or en-US.

Marking up a phrase in a different language

You are not limited to the whole page. Put lang on any element to mark a span of text in another language, which lets screen readers switch voices mid-sentence:

<p>
  She greeted us with a cheerful
  <span lang="fr">bonjour</span>
  before sitting down.
</p>

Here the surrounding page might be lang="en", while bonjour is announced with a French voice.

ISO 639-1 Language Codes

The table below lists the ISO 639-1 two-letter codes — the language subtag you place first in a BCP 47 tag. Languages that have no ISO 639-1 code are marked -; for those, use the ISO 639-2/639-3 three-letter code shown in the note after the dash.

See the list of ISO 639-1 language codes:

LanguageISO Code
Abkhazianab
Afaraa
Afrikaansaf
Albaniansq
Amharicam
Arabicar
Aragonesean
Armenianhy
Assameseas
Aymaraay
Azerbaijaniaz
Bashkirba
Basqueeu
Bengali (Bangla)bn
Dzongkhadz
Biharibh
Bislamabi
Bosnianbs
Bretonbr
Bulgarianbg
Burmesemy
Belarusianbe
Cambodiankm
Catalanca
Cherokee- (639-2/3: chr)
Chewa (Chichewa)ny
Chinesezh
Corsicanco
Croatianhr
Czechcs
Danishda
Divehi (Dhivehi)dv
Dutchnl
Edo- (639-2/3: bin)
Englishen
Esperantoeo
Estonianet
Faeroesefo
Farsifa
Fijifj
Finnishfi
Flemish (Dutch, Belgium)nl (region: nl-BE)
Frenchfr
Frisian (Western)fy
Fulah (Fulfulde)ff
Galiciangl
Gaelic (Scottish)gd
Gaelic (Manx)gv
Georgianka
Germande
Greekel
Greenlandickl
Guaranign
Gujaratigu
Haitian Creoleht
Hausaha
Hawaiian- (639-2/3: haw)
Hebrewhe
Hindihi
Hungarianhu
Ibibio- (639-2/3: ibb)
Icelandicis
Idoio
Igboig
Indonesianid
Interlinguaia
Interlingueie
Inuktitutiu
Inupiakik
Irishga
Italianit
Japaneseja
Javanesejv
Kannadakn
Kanurikr
Kashmiriks
Kazakhkk
Kinyarwanda (Rwanda)rw
Kirghizky
Kirundi (Rundi)rn
Konkani- (639-2/3: kok)
Koreanko
Kurdishku
Laothianlo
Latinla
Latvian (Lettish)lv
Limburgish (Limburger)li
Lingalaln
Lithuanianlt
Macedonianmk
Malagasymg
Malayms
Malayalamml
Maltesemt
Maorimi
Marathimr
Mongolianmn
Nauruna
Nepaline
Norwegianno
Occitanoc
Oriyaor
Oromo (Afaan Oromo)om
Papiamento- (639-2/3: pap)
Pashto (Pushto)ps
Polishpl
Portuguesept
Punjabipa
Quechuaqu
Rhaeto-Romancerm
Romanianro
Russianru
Sami (Northern)se
Samoansm
Sangosg
Sanskritsa
Serbiansr
Serbo-Croatiansh (deprecated; use sr, hr, or bs)
Sesotho (Southern Sotho)st
Setswanatn
Shonasn
Sichuan Yiii
Sindhisd
Sinhalesesi
Siswatiss
Slovaksk
Sloveniansl
Somaliso
Spanishes
Sundanesesu
Swahili (Kiswahili)sw
Swedishsv
Syriac- (639-2/3: syr)
Tagalogtl
Tajiktg
Tamazight (Central Atlas)- (639-3: tzm)
Tamilta
Tatartt
Telugute
Thaith
Tibetanbo
Tigrinyati
Tongato
Tsongats
Turkishtr
Turkmentk
Twitw
Uighurug
Ukrainianuk
Urduur
Uzbekuz
Vendave
Vietnamesevi
Volapükvo
Walloonwa
Welshcy
Wolofwo
Xhosaxh
Yiddishyi
Yorubayo
Zuluzu

Practice

Practice
Which value is a correctly formed BCP 47 language tag for the lang attribute?
Which value is a correctly formed BCP 47 language tag for the lang attribute?
Was this page helpful?