html tutorial - lang Attribute in HTML - html5 - html code - html form




Lang attribute in html

Learn html - html tutorial - Lang attribute in html - html examples - html programs

  • The lang attribute is used to declared the language of the document/content.
  • The lang attribute will guide the search engine and browsers to understand the basic language for the website.
  • Based on the ISO standard each language will have unique code to declare in lang attribute.
  • The lang attribute is a global attribute.
  • Example: English – en , Chinese – zn , Spanish - es

Syntax for lang attribute in HTML:

<element lang =”language_code”>

Difference between HTML 4.01 and HTML 5 for lang Attribute:

HTML 4.01

HTML 5

  • HTML 5, support the lang attribute.

Applies To:

Element Attribute
All HTML element lang

lang Attribute Values:

Value Description
lang lang attribute is used to specify the language code for an element’s contents.

Sample Coding for lang Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy lang attribute</title>
    </head>
    <body>
        <h2>This is a HTML lang attribute example</h2>
        <h3 lang="es">Bienvenido a Wikitechy!</h3>
    </body>
</html>

Code Explanation for lang Attribute in HTML:

lang Attribute Code Explanation

  1. lang attribute declared within the <h3> tag to define the language as “es” (spanish).

Output for lang Attribute in HTML:

lang Attribute Output

  1. The output shows the Spanish content. But the lang attribute value not visible to user that will be used to search engine for regional search results.

Browser Support for lang Attribute in HTML:

Yes Yes Yes Yes Yes

ISO Language Code:

Based on the w3c recommendations we should declare base or primary language for website and it should reflect in all the web pages.

Languages and ISO codes list

ISO Code Name
ab Abkhazian
Aa Afar
Af Afrikaans
Sq Albanian
Am Amharic
ar Arabic
an Aragonese
hy Armenian
as Assamese
ay Aymara
az Azerbaijani
ba Bashkir
eu Basque
bn Bengali(Bangla)
dz Bhutani
bh Bihari
bi Bislama
Br Breton
Bg Bulgarian
my Burmese
be Byelorussian (Belarusian)
km Cambodian
ca Catalan
zh Chinese
zh-Hans Chinese (Simplified)
zh-Hant Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
fo Faeroese
fa Farsi
fj Fiji
fi Finnish
fr French
Fy Frisian
Gv Gaelic (Manx)
Gd Gaelic (Scottish)
gl Galician
ka Georgian
de German
el Greek
kl Greenlandic
gu Gujarati
gn Gujarati
ht Haitian Creole
ha Hausa
he,iw Hebrew
hi Hindi
hu Hungarian
is Icelandic
io Ido
Id,in Indonesian
ia Interlingua
ie Interlingue
iu Inuktitut
ik Inupiak
ga Irish
it Italian
ja Japanese
jv Javanese
kn Kannada
ks Kashmiri
kk Kazakh
rw Kinyarwanda(Ruanda)
ky Kirghiz
rn Kirundi(Rundi)
ku Kurdish
lo Laothian
la Latin
lv Latvian(Lettish)
li Limburgish(Limburger)
ln Lingala
lt Lithuanian
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mo Moldavian
mn Mongolian
na Nauru
ne Nepali
no Norwegian
oc Occitan
or Oriya
om Oromo (Afaan Oromo)
ps Pashto (Pushto)
pl Polish
pt Portuguese
pa punjabi
qu Quechua
rm Rhaeto-Romance
ro Romainan
ru Russian
sm Samoan
sg Sangro
sa Sanskrit
sr Serbian
sh Serbo-Croatian
tn Setswana
sn Shona
ii Sichuan Yi
sd Sindhi
si sinhalese
ss Siswati
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili(Kiswahili)
sv Swedish
tl Tagalog
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
bo Tibetan
ti Tigrinya
to Tonga
ts Tsonga
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
uz Uzbek
ur Uzbek
vi Vietnamese
vo Volapük
wa Wallon
cy Welsh
wo Wolof
xh Xhosa
yi,ji Yiddish
yo Yoruba
zu Zulu

Related Searches to lang Attribute in html