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
orhttp-equiv
is specified, then thecontent
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 themeta
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 - 没有 `<meta>` 属性的 RDFa `name` 是否与 HTML5 兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59360473/