Loading lessons...
HTML Language Code Reference
Use the lang attribute to tell the browser what language your text is in. It helps screen readers, search engines, and spell checkers.
html
<html lang="en">
<p lang="fr">Bonjour tout le monde!</p>
The most common language codes
| Code | Language | Code | Language |
|---|---|---|---|
en | English | es | Spanish |
fr | French | de | German |
it | Italian | pt | Portuguese |
ru | Russian | zh | Chinese |
ja | Japanese | ko | Korean |
ar | Arabic | hi | Hindi |
nl | Dutch | sv | Swedish |
no | Norwegian | da | Danish |
fi | Finnish | pl | Polish |
tr | Turkish | el | Greek |
he | Hebrew | th | Thai |
vi | Vietnamese | id | Indonesian |
ms | Malay | uk | Ukrainian |
cs | Czech | hu | Hungarian |
ro | Romanian | bg | Bulgarian |
hr | Croatian | sk | Slovak |
sl | Slovenian | sr | Serbian |
fa | Persian | ur | Urdu |
bn | Bengali | ta | Tamil |
te | Telugu | mr | Marathi |
pa | Punjabi | sw | Swahili |
Country codes vs language codes
- The
langattribute uses LANGUAGE codes (en,fr). - The
hreflangattribute (on links) tells the language of the linked page. - Country codes like
US,GB,FRare for regions. You can combine them:en-US= English as spoken in the USA,en-GB= British English.
html
<html lang="en-US">
<html lang="en-GB">
Why it matters
- Screen readers pronounce text correctly.
- Search engines find content in the right language.
- Browsers offer to translate the page.
- Spell checkers use the right dictionary.
Script direction
Some languages read right-to-left. Set the direction too:
html
<html lang="ar" dir="rtl">
dir="rtl"= right-to-left (Arabic, Hebrew, Persian).dir="ltr"= left-to-right (default, English and most languages).
TL;DR
- Use
langon<html>(and on text in another language). en,es,fr,deare the most common codes.- Combine language + country:
en-US,pt-BR. - Add
dir="rtl"for right-to-left languages. - It helps screen readers, search, and translation!