Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the lang attribute of html5 refer to

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "what does the lang attribute of html5 refer to?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what the lang attribute of html5 refers to" article.

In html5, the full name lang is "language", which means "language" and is a global attribute that can be used for any HTML element; the lang attribute is used to specify the language of the element's content, and the syntax "".

The operating environment of this tutorial: windows7 system, HTML5 version, Dell G3 computer.

In html5, lang is called "language", which means "language".

Lang is a global attribute that can be used for any HTML element (it validates any HTML element. But it doesn't have to work.

In HTML 4.01, the lang attribute cannot be used to:

, and.

The lang attribute specifies the language of the element's content.

Syntax:

Value description value

The language code that specifies the content of the element.

A Language Tags consisting of four child tags from ① to ⑦. If you have any confusion, please refer to the documentation provided in the Resources section.

The meaning of each part

  ① language: the main language, with the code "zh" for Chinese, lowercase. There seems to be no mandatory requirement for case, it's just a habit. Follow the habit. Always making others look awkward is not a good way to show your personality.

  ② extlang: translated into "extended language"? For Chinese, this part represents Putonghua and dialects. For example, "cmn" means Putonghua, "yue" means Cantonese, and "lzh" I don't know what it means. Lowercase.

  ③ script: writing format, there is no spelling change in Chinese, only "simplified" and "traditional". "Hans" means simplified, "Hant" means traditional, and the first letter is capitalized.

  ④ region: the regions related to Chinese are probably Chinese mainland (CN), Taiwan (TW), Hong Kong, China (HK), Macao, China (MO) and Singapore (SG).

  ⑤⑥⑦: guess...

The troubles of dialects

I counted   . In addition to "cmn" for Putonghua, IANA has approved at least 13 dialect sub-tags, listed below:

     cdo 、 cjy 、 cpx 、 czh 、 czo 、 gan 、 hak 、 hsn 、 lzh 、 mnp 、 nan 、 wuu 、 yue

What is confusing about    is that these tags can be used as extlang child tags to represent dialects (extended languages? ) can also be placed in the language location as the main language So what is the relationship between these tags and the traditional "zh" tag? IANA defines "zh" as "macrolanguage". I don't know how to translate it. Macro language? Or the language family? BCP 47 holds that Chinese contains several languages, and it seems to think that Chinese dialects can be regarded as independent languages. Therefore, "zh" can still be used as the main language, and then mark the dialect in the location of the extlang, that is, this format. At the same time, it also supports the direct use of dialects as the main language, that is, such a format.

After    has figured out the confusion caused by dialects, my personal suggestion is to use "zh" as the main language. I don't want to engage in political discussions or study esoteric academic issues. The only reason I suggest using only "zh" as the subject sub-tag is to avoid confusion. At present, a few (if not many) dialect tags are still in a very happy state. Don't forget that there is a legend that dialects are used as secret words in counterattacks, while Harbin, Xi'an and Chengdu may be different dialects. Who knows how many Chinese languages the bosses of IANA will approve in the future and memorize them? Or when maintaining the code, first check whether this is a Chinese dialect or a foreign language in some nook and cranny.

   "zh" means Chinese; "zh-xxx" still means Chinese, but the dialect characteristics need to be taken into account. Such an expression will not lead to any misunderstanding.

The shorter the better.

The recommendation of the    W3C is: "The golden rule when creating language tags is to keep the tag as short as possible". Some parts of the label are really not necessary. For example, if applications such as speech synthesis are not involved, the existence of the extlang part is of little significance, no matter what dialect accent you have, you will write the same text. And the region part doesn't seem to make much sense to Chinese. Do you know the difference between Singaporeans speaking Putonghua and mainlanders? I'm not sure.

   so the W3C example becomes the best use-- "zh-Hans"-- in Chinese, simplified. That's enough. Or I personally think that only "zh" can be used, and there can be a mixture of simple and complicated ones.

Compatible

   traditionally uses "zh-CN". Is the new standard supported by all browsers? I really don't have the energy to try this, or is it safer to use "zh-Hans-CN" now?

The above is about the content of this article "what is the lang attribute of html5". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report