gpt4 book ai didi

html - 为什么我们在元标记中使用 lang 属性作为 html 属性告诉更多有关文档的信息?

转载 作者:行者123 更新时间:2023-12-04 16:32:50 27 4
gpt4 key购买 nike

我们使用元标记来告诉有关文档的更多信息。例如 lang HTML 标签上的属性,提供有关文档的更多信息。为什么我们不使用它作为 meta标签属性?
为什么我们在 HTML 中使用标签?

最佳答案

曾经有一个元标记来指示语言。<meta http-equiv="Content-Language" content="en-US">http-equiv 属性设置为提供与名称相似的 HTTP header 可以提供的信息等效的信息。
它试图模拟的 header 是 Content-Language: de, en .它是描述面向观众的语言。
从文档:

If "Content-Language: de-DE" is set, it says that the document is intended for German language speakers (however, it doesn't indicate the document is written in German. For example, it might be written in English as part of a language course for German speakers. If you want to indicate which language the document is written in, use the lang attribute instead).


因此,即使在它被弃用之前,它也有不同的目的。 lang属性用于定义元素的语言。它不表示任何目标受众,更多的是关于标签内的内容。可以戴 <p> , <li>等等。元素可能有不同语言的内容。您可以在具有不同语言的网页中使用不同的 div。定义一个 lang属性 in 有助于将其传播给所有 child ,除非被覆盖。

关于html - 为什么我们在元标记中使用 lang 属性作为 html 属性告诉更多有关文档的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68280006/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com