问题描述
我想知道使用lang属性的意义以及与使用metaContent-Language标签有什么不同?考虑下面的代码:
< html lang =en>
< head>
< meta http-equiv =Content-Languagecontent =en-US>
< / head> ...
我的假设是浏览器正在阅读元标记的值,但DOM与lang属性有关。它是否正确?是否有任何细微差别我不知道?
lang属性(在HTML元素上)指定文档的语言(除非用另一个可以改变文档段落语言的lang属性覆盖)。
Content-Language HTTP标头指定目标受众的语言。这与文档实际写入的语言不同。例如,法语语言课程的一部分可能包含用法语书写的页面,但Content-Language应该是 en ,因为它是旨在为英语学习者学习法语。
来自: b
$ b
Meta HTTP-equiv是穷人的HTTP头。它具有真正的HTTP标题的所有含义,但不受尊重(和支持)。
作为一个经验法则,内容语言对搜索引擎更感兴趣并且lang属性对屏幕阅读器更感兴趣。
I was wondering what's the significance of using the "lang" attribute and how that differs from using the meta "Content-Language" tag?
Consider the following code:
<html lang="en">
<head>
<meta http-equiv="Content-Language" content="en-US">
</head>...
My assumption is that the browser is reading the meta tag's value, but the DOM is concerned with the "lang" attribute. Is this correct? Are there any nuances I'm unaware of?
The lang attribute (on the HTML element) specifies the language for the document (unless overridden with another lang attribute which can change the language for a section of the document).
The Content-Language HTTP header specifies the language of the intended audience. This is not the same as the language the document is actually written in. For example, part of a French language course could consist of a page written in French, but Content-Language would be en as it was intended for English speakers learning French.
From the spec:
Meta HTTP-equiv is the poor man's HTTP header. It has all the meaning of the real HTTP header, but less respect (and support).
As a rule of thumb, Content-Language is of more interest to search engines and the lang attribute is of more interest to screen readers.
这篇关于lang属性和< meta http-equiv =“Content-Language”之间的区别是什么?含量="的en-US">标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!