From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/html/element/meta/index.html | 122 +++++++++ files/zh-cn/web/html/element/meta/name/index.html | 310 ++++++++++++++++++++++ 2 files changed, 432 insertions(+) create mode 100644 files/zh-cn/web/html/element/meta/index.html create mode 100644 files/zh-cn/web/html/element/meta/name/index.html (limited to 'files/zh-cn/web/html/element/meta') diff --git a/files/zh-cn/web/html/element/meta/index.html b/files/zh-cn/web/html/element/meta/index.html new file mode 100644 index 0000000000..4594e71125 --- /dev/null +++ b/files/zh-cn/web/html/element/meta/index.html @@ -0,0 +1,122 @@ +--- +title: :文档级元数据元素 +slug: Web/HTML/Element/meta +tags: + - HTML + - metadata + - 元数据 + - 元素 +translation_of: Web/HTML/Element/meta +--- +
{{HTMLRef}}
+ +

HTML <meta> 元素表示那些不能由其它 HTML 元相关(meta-related)元素(({{HTMLElement("base")}}、{{HTMLElement("link")}}, {{HTMLElement("script")}}、{{HTMLElement("style")}} 或 {{HTMLElement("title")}})之一表示的任何{{Glossary("Metadata","元数据")}}信息。

+ + + +

meta 元素定义的元数据的类型包括以下几种:

+ + + +

属性

+ +

此元素包括全局属性

+ +
+

注意: 全局属性 {{htmlattrxref("name", "meta")}} 在 {{HTMLElement("meta")}} 元素中具有特殊的语义;另外, 在同一个 <meta> 标签中,{{htmlattrxref("name", "meta")}}, {{htmlattrxref("http-equiv", "meta")}} 或者 {{htmlattrxref("charset", "meta")}} 三者中任何一个属性存在时,{{htmlattrxref("itemprop", "meta")}} 属性不能被使用。

+
+ +

{{htmlattrdef("charset")}}

+ +

这个属性声明了文档的字符编码。如果使用了这个属性,其值必须是与ASCII大小写无关(ASCII case-insensitive)的"utf-8"。

+ +
+
{{htmlattrdef("content")}}
+
此属性包含{{htmlattrxref("http-equiv", "meta")}} 或{{htmlattrxref("name", "meta")}} 属性的值,具体取决于所使用的值。
+
{{htmlattrdef("http-equiv")}}
+
属性定义了一个编译指示指令。这个属性叫做 http-equiv(alent) 是因为所有允许的值都是特定HTTP头部的名称,如下: +
    +
  • content-security-policy
    + 它允许页面作者定义当前页的内容策略。 内容策略主要指定允许的服务器源和脚本端点,这有助于防止跨站点脚本攻击。
  • +
  • content-type
    + 如果使用这个属性,其值必须是"text/html; charset=utf-8"。注意:该属性只能用于 MIME typetext/html 的文档,不能用于MIME类型为XML的文档。
  • +
  • default-style +

    设置默认 CSS 样式表组的名称。

    +
  • +
  • +

    x-ua-compatible
    + 如果指定,则 content 属性必须具有值 "IE=edge"。用户代理必须忽略此指示。

    +
  • +
  • refresh
    + 这个属性指定: +
      +
    • 如果 {{htmlattrxref("content", "meta")}} 只包含一个正整数,则为重新载入页面的时间间隔(秒);
    • +
    • 如果 {{htmlattrxref("content", "meta")}} 包含一个正整数,并且后面跟着字符串 ';url=' 和一个合法的 URL,则是重定向到指定链接的时间间隔(秒)
    • +
    +
  • +
+ +
可访问性相关考虑
+ +

设置了 refresh 值的页面可能有时间间隔太短的风险。使用诸如屏幕朗读这样的辅助技术来浏览网页的人可能会由于自动跳转而来不及读完或理解网页的内容。这样不经提示而突然进行的页面刷新也可能会让有视力障碍的人群感到迷惑。

+ + +
+
{{htmlattrdef("name")}}
+
namecontent 属性可以一起使用,以名-值对的方式给文档提供元数据,其中 name 作为元数据的名称,content 作为元数据的值。
+
标准元数据名称中查看 HTML 规范等规范中定义的标准元数据名称。
+
+ +

示例

+ +
<meta charset="utf-8">
+
+<!-- Redirect page after 3 seconds -->
+<meta http-equiv="refresh" content="3;url=https://www.mozilla.org">
+
+
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName('HTML WHATWG', 'semantics.html#the-meta-element', '<meta>')}}{{Spec2('HTML WHATWG')}}
+ +

浏览器兼容性

+ + + +
{{Compat("html.elements.meta")}}
diff --git a/files/zh-cn/web/html/element/meta/name/index.html b/files/zh-cn/web/html/element/meta/name/index.html new file mode 100644 index 0000000000..3f0b9fc74d --- /dev/null +++ b/files/zh-cn/web/html/element/meta/name/index.html @@ -0,0 +1,310 @@ +--- +title: 标准元数据名称 +slug: Web/HTML/Element/meta/name +tags: + - HTML + - 元数据 + - 参考 + - 属性 +translation_of: Web/HTML/Element/meta/name +--- +
{{HTMLRef}}
+ +

The {{htmlelement("meta")}} 元素可用于提供 名称-值 对形式的文档元数据,{{htmlattrxref("name", "meta")}} 属性为元数据条目提供名称,而 {{htmlattrxref("content", "meta")}} 属性提供值。

+ +

HTML 规范中定义的标准元数据名称

+ +

HTML 规范定义了以下标准元数据名称:

+ + + +

其他规范中定义的标准元数据名称

+ +

CSS 颜色调整规范(CSS Color Adjustment specification)定义了以下元数据名称:

+ + + +

CSS 设备适配规范(CSS Device Adaptation specification)定义了以下元数据名称:

+ + + +

其他元数据名称

+ +

The WHATWG Wiki MetaExtensions page contains a large set of non-standard metadata names that have not been formally accepted yet; however, some of the names included there are already used quite commonly in practice — including the following:

+ + + +

规范

+ + + + + + + + + + + + + + + + + + + + + +
规范
{{SpecName('HTML WHATWG', '#standard-metadata-names', 'standard metadata names')}}
{{SpecName('CSS Color Adjust', '#color-scheme-meta', 'the "color-scheme" metadata name')}}
{{SpecName('CSS3 Device', '#viewport-meta', 'the "viewport" metadata name')}}
{{SpecName('Referrer Policy', '#referrer-policy-delivery-meta', 'the "referrer" metadata name')}}
+ +

浏览器兼容性

+ + + +

{{Compat("html.elements.meta.name")}}

-- cgit v1.2.3-54-g00ecf