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

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

问题描述

在HTML中,在< html> 中有一个lang属性,例如< html lang =en>

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

这有用吗?

如果将其用于翻译,即使语言设置为英语,并且文档中的所有中文文本都会将其检测为Google翻译中文而非英文(这意味着Google会忽略 lang 属性) 解决方案

If this is used for translation, even if 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

解决方案

a>


在HTML中声明语言

Declaring language in HTML

总是在html标签上使用语言属性来声明默认页面中文字的语言。当页面包含另一种语言的内容时,将语言属性添加到围绕该内容的元素。

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.

使用lang属性作为HTML提供页面,xml:lang用作XML的页面的属性。对于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语言子标签注册表中的语言标签。

Use language tags from the IANA Language Subtag Registry.

也很好阅读 为什么要使用language属性?

also good read Why use the language attribute?

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

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