What is a valid Hreflang?

Sometimes users of our Hreflang testing tool see an error like this and get baffled:

Invalid hreflang (en_US) found in HTML.

Why is en_US incorrect? Because the correct way to write a language code is with dashes, not underscores. The correct value is en-US.

What are valid values for Hreflang?

A valid hreflang can be specified as:

  • A 2-character language code (e.g. “en”), or
  • a combination of language and region code (e.g. “en-US”), or
  • a combination of language and script code (e.g. “sr-Cyrl” or “sr-Latn”), or
  • a combination of language, script and region codes (e.g. “sr-hu-Latn”)
  • A special value of “x-default”, used for country/language selectors and redirector pages. These pages are not specific to any language/locale. Users either choose their language/country (e.g. from a map or dropdown box), or the website uses the IP address of the visitor to this page and automatically redirects them to the page that is appropriate for them.

Examples of invalid Hreflang

Here are some examples of invalid language codes found recently by the online testing tool. See if you can figure out why these codes are incorrect:

  • en_US: Underscore used instead of hyphen
  • en-en: The second “en” is incorrect because “en” is not a valid region code.
  • en-UK: “uk” is not a valid region code. Use “en-GB”.
  • us-en: The order is inverted. It should be “en-US”.
  • ua: ua is not a language code. It is a region code. So it is incorrect to use it by itself, i.e. without a language code.
  • cmn-CN: The country code for China is correct (this page was in Chinese and the URL was a .cn URL. The language code is incorrect.

Valid Codes for Reference

Valid Language Codes (2-character ISO-639-1 Codes)

A list of valid 2-character language codes is as follows (the format is ISO 639-1):

aa, ab, ae, af, ak, am, an, ar, as, av, ay, az, ba, be, bg, bh, bi, bm, bn, bo, br, bs, ca, ce, ch, co, cr, cs, cu, cv, cy, da, de, dv, dz, ee, el, en, eo, es, et, eu, fa, ff, fi, fj, fo, fr, fy, ga, gd, gl, gn, gu, gv, ha, he, hi, ho, hr, ht, hu, hy, hz, ia, id, ie, ig, ii, ik, io, is, it, iu, ja, jv, ka, kg, ki, kj, kk, kl, km, kn, ko, kr, ks, ku, kv, kw, ky, la, lb, lg, li, ln, lo, lt, lu, lv, mg, mh, mi, mk, ml, mn, mr, ms, mt, my, na, nb, nd, ne, ng, nl, nn, no, nr, nv, ny, oc, oj, om, or, os, pa, pi, pl, ps, pt, qu, rm, rn, ro, ru, rw, sa, sc, sd, se, sg, si, sk, sl, sm, sn, so, sq, sr, ss, st, su, sv, sw, ta, te, tg, th, ti, tk, tl, tn, to, tr, ts, tt, tw, ty, ug, uk, ur, uz, ve, vi, vo, wa, wo, xh, yi, yo, za, zh, zu

Valid Region Codes (2-character ISO-3166-1 Codes)

And here are all the valid region codes (ISO 3166-1 Alpha 2 format; note that the code for the United Kingdom is “GB”, not “UK”):

AD, AE, AF, AG, AI, AL, AM, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MH, MK, ML, MM, MN, MO, MP, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, ZA, ZM, ZW

Valid Script Codes (4-character ISO 15924 Codes)

All valid script codes are as follows (the format is ISO 15924):

Adlm, Afak, Aghb, Ahom, Arab, Aran, Armi, Armn, Avst, Bali, Bamu, Bass, Batk, Beng, Bhks, Blis, Bopo, Brah, Brai, Bugi, Buhd, Cakm, Cans, Cari, Cham, Cher, Cirt, Copt, Cprt, Cyrl, Cyrs, Deva, Dsrt, Dupl, Egyd, Egyh, Egyp, Elba, Ethi, Geok, Geor, Glag, Goth, Gran, Grek, Gujr, Guru, Hang, Hani, Hano, Hans, Hant, Hatr, Hebr, Hira, Hluw, Hmng, Hrkt, Hung, Inds, Ital, Java, Jpan, Jurc, Kali, Kana, Khar, Khmr, Khoj, Kitl, Kits, Knda, Kore, Kpel, Kthi, Lana, Laoo, Latf, Latg, Latn, Leke, Lepc, Limb, Lina, Linb, Lisu, Loma, Lyci, Lydi, Mahj, Mand, Mani, Marc, Maya, Mend, Merc, Mero, Mlym, Modi, Mong, Moon, Mroo, Mtei, Mult, Mymr, Narb, Nbat, Nkgb, Nkoo, Nshu, Ogam, Olck, Orkh, Orya, Osge, Osma, Palm, Pauc, Perm, Phag, Phli, Phlp, Phlv, Phnx, Plrd, Prti, Rjng, Roro, Runr, Samr, Sara, Sarb, Saur, Sgnw, Shaw, Shrd, Sidd, Sind, Sinh, Sora, Sund, Sylo, Syrc, Syre, Syrj, Syrn, Tagb, Takr, Tale, Talu, Taml, Tang, Tavt, Telu, Teng, Tfng, Tglg, Thaa, Thai, Tibt, Tirh, Ugar, Vaii, Visp, Wara, Wole, Xpeo, Xsux, Yiii

Further reading

Use hreflang for language and regional URLs (by Google)

Published by

Nick Jasuja

Nick Jasuja is the founder of Hreflang.org and Diffen, the world's largest collection of unbiased comparisons. Diffen's expansion to Spanish was Nick's first foray into international SEO and motivated him to launch the Hreflang testing tool. You can find him on Twitter @thisislobo.