When I first started learning HTML, THERE was something I didn’t understand about the basic HTML format. The basic format is as follows:

<! DOCTYPEhtml>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body></body>
</html>
Copy the code
<html lang='en'></html>/ / English<html lang='zh'></html>/ / Chinese<html lang='ja'></html>/ / Japanese<html lang='en-us'></html>// American English<html lang='fr'></html>/ / French<html lang='da'></html>/ / German<html lang='it'></html>// Italian<html lang='ko'></html>/ / Korean<html lang='pl'></html>/ / polish<html lang='ru'></html>/ / Russian<html lang='es'></html>// SpanishCopy the code

 

What exactly is the lang attribute in an HTML tag? Why specify its value as “en” or “zh-cn”? My personal views are as follows:

1. Attribute lang is the abbreviation of English language, which means language. “en” stands for English and “zh-cn” stands for Chinese

2. In my own experiment, I found that without the lang attribute, the entire HTML document was displayed without any problems

3. As we all know, if you are in China, the default language of the local browser is Chinese. When we open a foreign website, the browser will prompt us “Whether to translate the webpage content into Chinese”, as shown below:

Check the page source code, find lang = “en” (I log in is http://www.csszengarden.com/)

4. Log in several Chinese local websites, and find that there is no lang attribute written in the source code, and no hint of translation

5. The search engine itself cannot determine the language of the page it is fetching because it looks like a binary file, so it needs to be told what language the page is in so that it can know what to do next. In other words, when you set lang to “en”, No matter what language your web page is in, it will look like English, and if the default language of the local browser is not English, it will prompt you with the option above and ask if you want to translate. This is clearly visible in the browser Settings:

Conclusion: 1. The search engine could not judge what is the contents of the page language, need people to tell it (here also reflects the semantic characteristics of the machine itself what all don’t understand, we need to tell it what it is, and when we tell it what it is, we must also do as this rule, otherwise set lang to “en”, However, we use Chinese language content in our web pages, which will greatly interfere with the machine, and thus interfere with the normal user experience, which makes no sense. 2. The browser will compare the language of the page read with the local language. If the language is the same, the browser will not process it.