Home > Article > Web Front-end > The role of lang in html tags
This article mainly introduces the role of lang in html tags. Interested friends can refer to it. I hope it will be helpful to everyone.
The lang attribute written in the html tag functions: declares the language type of the current page.
For example:
<html lang='en'></html> //英文
<html lang='zh'></html> //中文
<html lang='ja'></html> //日文
<html lang='en-us'></html> //美式英文
Note: The language code in the lang attribute is not case-sensitive
<html lang='en-us'></html> //英文
<html lang='en-us'></html> //英文
The above two lines of code have the same effect.
In addition, the lang attribute can also be added to ordinary tags.
For example:
<p lang='en'>this is English .</p>
lang attribute--HTML language declaration attribute
<html xmlns="http://www.php.cn" lang="en" xml:lang="en"> <html xmlns="http://www.php.cn" lang="zh-CN" xml:lang="zh-CN">
en
Definition language is English
zh-CN
Definition language is Chinese
If the web page is defined as XHTML1.1 or XML format, you can use the xml:lang attribute (because the xml:lang attribute is the standard usage to determine language information in XML).
If the web page uses HTML format, you should use both xml:lang and lang attributes.
##Definition and usage
<element lang="language_code"
zh-Hans/zh-Hant表示简体和繁体。
zh-cmn-Hans表示简体中文书写的国语。Example of how to tag 1, Simplified Chinese page: html 2, Traditional Chinese page: html 3, English page: htm4, Audio - Mandarin singing: audio 5, Audio - Cantonese singing: audio Note that 4 and 5 are audio and should not be marked with Hans/Hant. There are relatively few cases where it is necessary to add a region code, unless it is to emphasize the differences in the use of Chinese in different regions, such as:
zh-cmn-Hans-CN 普通话 (简体, 中国大陆)
zh-cmn-Hant-TW 普通话 (繁体, 台湾)
<p lang="zh-cmn-Hans"> <b lang="zh-cmn-Hans-CN">菠萝</b> <b lang="zh-cmn-Hant-TW">鳳梨</b> </p>Related recommendations:
html specifies the language attribute lang of the element content
Detailed introduction to the java.lang.Void class source code
Detailed explanation of commonly used tool classes under the Lang package in Java
The above is the detailed content of The role of lang in html tags. For more information, please follow other related articles on the PHP Chinese website!