< html>的'lang'属性是什么?标签用于? [英] What is the 'lang' attribute of the <html> tag used for?

查看:176
本文介绍了< html>的'lang'属性是什么?标签用于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML中,最好在<html>中具有lang属性,例如<html lang="en">.

In HTML, it's good to have a lang attribute in <html>, e.g. <html lang="en">.

这有什么用?

如果将其用于翻译,则即使语言设置为英语,并且文档 Google Translate 中所有中文文本都将其检测为中文,而不是英语(这意味着Google忽略lang属性).

If this is used for translation, even if the language is set to English and there are all Chinese text in the document Google Translate detects it as Chinese, not English (this means Google ignores the lang attribute).

推荐答案

我引用了 W3C :

用HTML声明语言

始终使用html标记上的language属性来声明页面中文本的默认语言.当页面包含另一种语言的内容时,请将language属性添加到该内容周围的元素中.

Always use a language attribute on the html tag to declare the default language of the text in the page. When the page contains content in another language, add a language attribute to an element surrounding that content.

对于用作HTML的页面使用lang属性,对于用作XML的页面使用xml:lang属性.对于XHTML 1.x和HTML5多语言文档,请同时使用两者.

Use the lang attribute for pages served as HTML, and the xml:lang attribute for pages served as XML. For XHTML 1.x and HTML5 polyglot documents, use both together.

使用 IANA语言子标签注册表 中的语言标签 .

也是很好的阅读方法. ="a href =" http://www.w3.org/International/questions/qa-lang-why.en"rel =" noreferrer>为什么要使用language属性? .

这篇关于&lt; html&gt;的'lang'属性是什么?标签用于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆