开放图形验证HTML5 [英] Open Graph validation for HTML5

查看:129
本文介绍了开放图形验证HTML5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的doctype是<!DOCTYPE html> (HTML5),是否有任何方法可以让Facebook的开放图表元标记得到验证?

Is there any way to get facebook's crappy Open Graph meta tags to validate if my doctype is <!DOCTYPE html> (HTML5)?

除了Facebook的Open Graph元标签外,我的文档完美验证。

Other than facebook's Open Graph meta tags, my document validates perfectly.

我真的不想使用<!DOCTYPE html PUBLIC - // W3C // DTD XHTML + RDFa 1.0 // ENhttp://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\">因为这样会产生一整套新的问题。

I really don't want to use <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> as that creates a whole new set of problems.

下面是一个有问题的验证错误之一...

Here is an example of one of the validation errors in question...

错误行11,列47:此时元素元素不允许使用属性属性。

Error Line 11, Column 47: Attribute property not allowed on element meta at this point.

<meta property="og:type" content="website" />

任何帮助将不胜感激...我一直在搜索,几天没有效果。

Any help would be appreciated... I have been searching off and on for days to no avail.

推荐答案

对于HTML5,将其添加到您的 html 元素如在ogp.me上所述,并保留您的 og:前缀属性的



For HTML5, add this to your html element like described on ogp.me and keep your og: prefixed property's:

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
     <meta property="og:type" content="website" />
     ...






对于XHTML如OP的问题),使用名称属性而不是属性属性。 Facebook lint会发出警告,但元数据仍将被识别和解析。


For XHTML (like OP's question), use the name attribute instead of property attribute. Facebook lint will throw a warning, but the meta value will still be recognized and parsed.

<meta name="og:title" content="Hello Facebook" />

这篇关于开放图形验证HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆