内容语言的 HTML 元标记
以下两个用于指定西班牙语网页内容的 HTML 元标记有什么区别:
<meta name="language" content="Spanish">
和
<meta http-equiv="content-language" content="es">
What is the difference between the following two HTML meta tags, for specifying spanish web page content:
<meta name="language" content="Spanish">
and
<meta http-equiv="content-language" content="es">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Google 建议使用 hreflang,请阅读更多信息
示例:
Google recommends to use hreflang, read more info
Examples:
Html5 也推荐使用
小写字母lang标签仅指定:语言代码
大字母指定:国家/地区代码
当浏览器建议翻译网页内容(即谷歌翻译)时,这对于 ie.Chrome 来说非常有用
Html5 also recommend to use
<html lang="es-ES">
The small letter lang tag only specifies: language code
The large letter specifies: country code
This is really useful for ie.Chrome, when the browser is proposing to translate web content(ie google translate)
另一种语言元标记是 og:locale,您可以为社交媒体定义 og:locale 元标记,
您可以在以下位置阅读有关 og 标记的信息
https://ogp.me/
another language meta tag is og:locale and you can define og:locale meta tag for social media
you can read about og tags in
https://ogp.me/
作为对其他答案的补充,请注意,您还可以将
lang
属性放在页面内的各种 HTML 标记上。例如,向拼写检查器提示输入文本应为英文:
...
请参阅:https://developer .mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
As a complement to other answers note that you can also put the
lang
attribute on various HTML tags inside a page.For example to give a hint to the spellchecker that the input text should be in english:
<input ... spellcheck="true" lang="en"> ...
See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
这在任何规范中均未定义(包括 HTML5 草案)
这是真实 HTTP 标头的穷人版本,应该真正在标头中表达。例如:
它说该文档适用于西班牙语使用者(但这并不意味着该文档是用西班牙语编写的;例如,它可以用英语编写,作为西班牙语使用者语言课程的一部分)。
来自规范:
如果您想声明文档是用西班牙语编写的,则使用:
This isn't defined in any specification (including the HTML5 draft)
This is a poor man's version of a real HTTP header and should really be expressed in the headers. For example:
It says that the document is intended for Spanish language speakers (it doesn't, however mean the document is written in Spanish; it could, for example, be written in English as part of a language course for Spanish speakers).
From the spec:
If you want to state that a document is written in Spanish then use:
您要求差异,但您无法完全比较这两者。
请注意
已过时并在 HTML5 中删除。它用于指定“文档范围内的默认语言”,其
http-equiv
属性使其成为pragma 指令(模拟 HTTP 响应标头,例如Content-Language
尚未是从服务器发送的,因为它不能覆盖真实的)。关于
,你几乎找不到任何可靠的信息。它是非标准的,可能是作为 SEO 权宜之计而发明的< /a>.
但是,HTML5 W3C 建议书鼓励作者使用
上的
根元素(属性值必须是有效的 BCP 47 语言标记 ):lang
属性html无论如何,如果您想指定内容语言来指示搜索引擎机器人,您应该考虑 多语言网站上的 Google Search Console 帮助:
You asked for differences, but you can’t quite compare those two.
Note that
<meta http-equiv="content-language" content="es">
is obsolete and removed in HTML5. It was used to specify “a document-wide default language”, with itshttp-equiv
attribute making it a pragma directive (which simulates an HTTP response header likeContent-Language
that hasn’t been sent from the server, since it cannot override a real one).Regarding
<meta name="language" content="Spanish">
, you hardly find any reliable information. It’s non-standard and was probably invented as a SEO makeshift.However, the HTML5 W3C Recommendation encourages authors to use the
lang
attribute onhtml
root elements (attribute values must be valid BCP 47 language tags):Anyway, if you want to specify the content language to instruct search engine robots, you should consider this quote from Google Search Console Help on multilingual sites: