Html 是否可以验证 xmlns:fb (Facebook) 属性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8696026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to validate the xmlns:fb (Facebook) attribute?
提问by DisgruntledGoat
I have a Facebook Like button on my site and as such also have the xmlns:fb
attribute on the <html>
tag:
我的网站上有一个 Facebook Like 按钮xmlns:fb
,因此<html>
标签上也有这个属性:
<!DOCTYPE html>
<html lang="en" xmlns:fb="http://www.facebook.com/2008/fbml">
However, when running my site through the W3C validator, I get these errors:
但是,当通过 W3C 验证器运行我的网站时,我收到以下错误:
Line 2, Column 61: Attribute xmlns:fb not allowed here.
Line 2, Column 61: Attribute with the local name xmlns:fb is not serializable as XML 1.0.
Line 222, Column 72: Attribute fb:like:layout is not serializable as XML 1.0.
Line 222, Column 72: Attribute fb:like:layout not allowed on element a at this point.
第 2 行,第 61 列:此处不允许使用属性 xmlns:fb。
第 2 行,第 61 列:具有本地名称 xmlns:fb 的属性不可序列化为 XML 1.0。
第 222 行,第 72 列:属性 fb:like:layout 不可序列化为 XML 1.0。
第 222 行,第 72 列:此时元素 a 上不允许使用属性 fb:like:layout。
It is my understanding that using the xmlns:fb
attribute adds fb
to the document namespace, so that using any <fb:
element is valid. Is that not the case? Is it a HTML5 issue?
我的理解是使用xmlns:fb
属性会添加fb
到文档命名空间,因此使用任何<fb:
元素都是有效的。不是这样吗?这是 HTML5 问题吗?
I also have similar validation errors with the Twitter button, is it possible to fix those as well?
我的 Twitter 按钮也有类似的验证错误,是否也可以修复这些错误?
Line 223, Column 53: Attribute tw:via is not serializable as XML 1.0.
Line 223, Column 53: Attribute tw:via not allowed on element a at this point.
第 223 行,第 53 列:属性 tw:via 不可序列化为 XML 1.0。
第 223 行,第 53 列:此时元素 a 上不允许使用属性 tw:via。
采纳答案by copy
There is no way to validate xmlns:fb
with HTML5.
无法xmlns:fb
使用 HTML5进行验证。
However, you can use the new data-...
-attributes, which were added by Facebook and are valid HTML5, as described here.
但是,您可以使用新的data-...
-attributes,这是由Facebook的加入是有效的HTML5,描述在这里。
This is an example of how you can use this extension in HTML5 (assume all code is in the body element):
这是一个如何在 HTML5 中使用此扩展的示例(假设所有代码都在 body 元素中):
<h3>Members</h3>
<embed data-fb="login-button" data-show-faces="true" />
<h3>Recent activity</h3>
<embed data-fb="activity" data-site="***" data-width="200" data-header="false"
data-border_color="#fff" data-recommendations="false" />
<div id="fb-root"></div>
<!-- the JavaScript API -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<!-- the extention script from this article -->
<script src="/scripts/fb.js"></script>
<script>
//<![CDATA[
FB.init({apiKey: '***', appId: '***', status: true, cookie: true, fbml5: true});
//]]>
</script>
This would be the equivalent XHTML code:
这将是等效的 XHTML 代码:
<h3>Members</h3>
<fb:login-button show-faces="true" />
<h3>Recent activity</h3>
<fb:activity site="***" width="200" header="false"
border_color="#fff" recommendations="false" />
<div id="fb-root"></div>
<!-- the JavaScript API -->
<script src="http://connect.facebook.net/en_US/all.js"></script>
<!-- the extention script from this article -->
<script src="/scripts/fb.js"></script>
<script>
//<![CDATA[
FB.init({apiKey: '***', appId: '***', status: true, cookie: true, fbml5: true});
//]]>
</script>
回答by Jeremy French
Or you can now use prefix mappings.
或者您现在可以使用前缀映射。
<!DOCTYPE html>
<html lang="en" prefix="fb: http://www.facebook.com/2008/fbml">