DESCRIPTION html lang attribute in the HTML element

DESCRIPTION html lang attribute in the HTML element

When I was just beginning to learn HTML and basic HTML format on one thing do not understand, the basic format is as follows

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body></body>
</html>

What lang attribute html tag is doing it? Why specify its value is "en" or "zh-CN" it? Personal opinion as follows:

1. lang attribute is the abbreviation of the English language, meaning the language, "en" for English, "zh-CN" on behalf of Chinese

2. In my own attempt to find, in fact, do not write the lang attribute, display the entire HTML document is no problem

3. We all know that if you are in China, local browser default language is Chinese, when we open a foreign site, the browser will prompt "whether to translate pages into Chinese", as shown

 

 

Check the page's source code and found lang = "en" (I landed a http://www.csszengarden.com/)

4. Log in several Chinese local site and found the source code does not write the lang attribute, there is no translation tips

The first search engine he could not judge the content they crawl the page is what language, because in its view are binary files, then we need to tell it about this page in what language, then it can know why the next step, that is, when you put lang is set to "en", no matter what is the content of your website in the language, in its view are in English, if the local browser's default language is not English, You will prompt the above options, ask whether you need to translate. This can be clearly seen in the browser's settings:

 

 

Summary: 1. search engines can not determine the content of the page in what language, need people to tell it (here also reflects the semantic characteristics that the machines themselves do not understand anything, we need to tell it what it is, and when we tell What is it, we must do it in accordance with this rule, or the lang is set to "en", but we use the Chinese language content on the page, which largely will interfere with the machine, and then to interference the user's normal experience, to do so would be meaningless.)
2. the browser will read the page language and the local language are compared to determine if the same, not treated, otherwise prompt the need for translation (of course, provided that the user hook choose this feature, chrome checked by default)

Digression: It reminds me of when I had graduated from college and so Albert located, frantic to find information on a variety of websites, web content obviously the investigation is Chinese, but still remind me if you want to translate, it seems, turned out to be web design unreasonable, lang will be set to "en", although does not affect the normal use, but for users it is baffling, at least that I was forced to look ignorant, "What the hell?" in addition, several saw domestic sites, and did not set the lang attribute, I wonder if I'm too stupid, or just that a user must be the Chinese people? Baidu no, no Taobao, CSDN nor, fortunately Tencent ...

Guess you like

Origin www.cnblogs.com/xsd1/p/11953814.html