The lang attribute on a <p> tag specifies the language of the paragraph text.
Its value used for site accessibility, translations, and SEO purposes.
A lang
attribute on 3 <p> elements.
A different language is identified for each paragraph.
This text is displayed in English.
Este texto se muestra en español.
이 텍스트는 한국어로 표시됩니다.
<p lang="en" style="background-color:aliceblue;padding:25px;">
This text is displayed in English.
</p>
<p lang="es" style="background-color:aliceblue;padding:25px;">
Este texto se muestra en español.
</p>
<p lang="ko" style="background-color:aliceblue;padding:25px;">
이 텍스트는 한국어로 표시됩니다.
</p>
The lang attribute specifies the language used in a paragraph.
The first two characters of the lang value refers to the language code.
The last two characters - which are optional - refer to the country code.
<p lang="language-code-country-code">
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). |
Here is when lang support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |