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

标签 html facebook-opengraph rdfa

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/

相关文章:

javascript - 设置数据列表的默认值不允许用户更改选择

javascript - 当 skiplocationchange 为真时返回 Angular 6

android facebook sdk 4.2 open graph 故事和 map

javascript - 用于在 javascript 中呈现的视频的 RDFa

html - 样式表链接中的 href 属性在 Node 中不起作用

html - 使用 DIV 而不是 CLASS 的情况

html - 我设置 og :type with 'article' but why og type always show on default 'website'

facebook - 在 FB.init 中设置用户(访问 token )

html - 如何添加多个标签(文章 : tag) in Facebook Open Graph?

rdf - RDFa是如何使用的?