The lang
attribute specifies the language of an element‘s content.
Its value is used for site accessibility, translations, and SEO purposes.
Three <p> tags with different lang
attributes.
The languages are English, Spanish, and Korean.
This text is displayed in English.
Este texto se muestra en español.
이 텍스트는 한국어로 표시됩니다.
<p lang="en" style="background-color:#f6f8ff;padding:25px;">
This text is displayed in English.
</p>
<p lang="es" style="background-color:#f6f8ff;padding:25px;">
Este texto se muestra en español.
</p>
<p lang="ko" style="background-color:#f6f8ff;padding:25px;">
이 텍스트는 한국어로 표시됩니다.
</p>
The lang
attribute specifies the language of an element's content.
This attribute is used for site accessibility, translations, and SEO purposes.
The lang
value must be a 2-character value from the ISO Language Code list.
Example values: en for English, de for German, zh for Chinese, and zu for Zulu.
Values can also include region, such as en-GB, for English from Great Britain
Note: lang
is a global attribute that can be applied to any tag.
Note: The lang
attribute has no visual effect. It only adds semantics, i.e. additional meaning, to an element.
<tag lang="lang" />
Value | Description |
---|---|
language-code-country-code |
The first 2 characters represent the language code of the page. The last two characters represent the country code (optional). |
The lang
attribute is a global attribute that can be applied to any element.
However, it is meaningful only on elements with text. Which are these?
Here are some elements:
lang
on <html> defines the language for a pagelang
on <p> defines the language for a paragraphlang
on <input> defines the language for an input controllang
on <textarea> defines the language for a textareaHere is when lang
support started for each browser:
Chrome
|
4 | Jan 2010 |
Firefox
|
2 | Oct 2006 |
IE/Edge
|
1 | Oct 2013 |
Opera
|
15 | Jul 2013 |
Safari
|
6 | Jul 2012 |