内容语言的 HTML 元标记

2022-01-18 00:00:00 internationalization html meta-tags

以下两个 HTML 元标记有什么区别,用于指定西班牙网页内容:

What is the difference between the following two HTML meta tags, for specifying spanish web page content:

<meta name="language" content="Spanish">

<meta http-equiv="content-language" content="es">

推荐答案

<元名称=语言";content=西班牙语">

这没有在任何规范中定义(包括 HTML5 草案)

This isn't defined in any specification (including the HTML5 draft)

这是一个真正的 HTTP 标头的穷人版本,应该在标头中真正表达出来.例如:

This is a poor man's version of a real HTTP header and should really be expressed in the headers. For example:

Content-language: es
Content-type: text/html;charset=UTF-8

它表示该文档是为说西班牙语的人准备的(但这并不意味着该文档是用西班牙语编写的;例如,它可以用英语编写,作为针对说西班牙语的语言课程的一部分).

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).

来自规范:

Content-Language entity-header 字段描述了封闭实体的目标受众的自然语言.请注意,这可能不等同于实体主体中使用的所有语言.

The Content-Language entity-header field describes the natural language(s) of the intended audience for the enclosed entity. Note that this might not be equivalent to all the languages used within the entity-body.

如果您想声明文档是用西班牙语编写的,那么 使用:

If you want to state that a document is written in Spanish then use:

<html lang="es">

相关文章