gpt4 book ai didi

html - 没有 `<meta>` 属性的 RDFa `name` 是否与 HTML5 兼容?

转载 作者:行者123 更新时间:2023-12-01 00:10:21 25 4
gpt4 key购买 nike

RDFa 推出了 property attribute对于<meta>元素,W3C 甚至 recommends this as an extension to HTML5 . Facebook的Open Graph例如,协议(protocol)使用 RDFa property像这样的属性(来自 Open Graph 站点的示例):

<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />


然而,HTML5 规范似乎禁止这种用法。我不是在谈论它是否允许 property属性;我指的是它明确禁止 content没有 name 的属性 the <meta> element 的属性:

If either name or http-equiv is specified, then the content attribute must also be specified. Otherwise, it must be omitted.



这与当前 RDFa 的使用(例如在 Open Graph 中)不是直接冲突吗? HTML5 规范似乎要求存在 name属性也在这里。

最佳答案

W3C 推荐“HTML+RDFa 1.1”extends HTML 规范(您可以在 W3C 注释中找到 all extensions)。

此扩展更改了 HTML 对 meta 的一致性要求。元素:

If the RDFa @property attribute is present on the meta element, neither the @name, @http-equiv, nor @charset attributes are required and the @content attribute MUST be specified.



所以,这两个 HTML+RDFa 元素是有效的:

<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />

(另外两个 meta 元素是无效的,因为它们具有 URL 值,其中 the link element must be used instead 。)

关于html - 没有 `&lt;meta&gt;` 属性的 RDFa `name` 是否与 HTML5 兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59360473/

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