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 is the purpose of the html lang attribute

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

Share

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

The main content of this article is to explain "what is the role of html lang attributes", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what is the role of html lang attributes"!

In html, lang is a global attribute that specifies the language and syntax of the element's content; it is commonly used in the "" tag to declare the language type of the current page.

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

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

In HTML5, the lang attribute can be used for any HTML element (that is, a global attribute).

Syntax:

Language_code specifies the language code for the content of the element. Language code reference manual. Language Code reference Manual

The lang attribute is typically used in the "" tag to declare the language type of the current page.

Description of the lang attribute of the html element in HTML

When I first started learning HTML, there was one thing I didn't understand about the basic HTML format. The basic format is as follows:

What exactly does the lang attribute in the html tag do? Why specify its value as "en" or "zh-CN"? My personal opinions are as follows:

1. Attribute lang is the abbreviation of English language, which means language. "en" represents English and "zh-CN" stands for Chinese.

2. Under my own attempt, I found that there is no problem with the display of the whole HTML document without writing the lang attribute.

3. We all know that if you are in China, the default language of the local browser is Chinese. When we open a foreign website, the browser will prompt "whether to translate the web content into Chinese", as shown in the following figure.

Check the source code of the page and find that lang= "en"

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

5. First of all, the search engine cannot determine the language of the content in the page it crawled, because it looks like a binary file, so it needs us to tell it what language the content on this page is, and then it can know what to do next. That is to say, when you set lang to "en", no matter what language the content is in your web page, it looks like English. If the default language of the local browser is not English, you will be prompted with the above option and asked if you need a translation. This can be clearly seen in the browser settings:

At this point, I believe you have a deeper understanding of "what is the role of html lang attributes", you might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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