w3c validator shows error for facebook open graph

2019-02-19 18:07发布

问题:

I get 2 errors while validating my site in w3c validator.

Line 7, Column 47: Attribute xmlns:og not allowed here. xmlns:fb="http://www.facebook.com/2008/fbml" >

Line 7, Column 47: Attribute with the local name xmlns:fb is not serializable as XML 1.0. xmlns:fb="http://www.facebook.com/2008/fbml" >

I guess it is related with Facebook open graph. I'm running my site on wordpress and using All in one SEO pack with Social features enabled. When Social feature is disabled, my site validates perfectly with no errors. Is there any fix to this problem? This is how it looks on site

<!DOCTYPE html>

<!--// OPEN HTML //-->
<html lang="en-US"
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:og="http://ogp.me/ns#" 
    xmlns:fb="http://www.facebook.com/2008/fbml" >

    <!--// OPEN HEAD //-->
    <head>

        <!--// SITE TITLE //-->
        <title>Aton usluge | Licencirana agencija za kreditno posredovanje</title>


        <!--// SITE META //-->
        <meta charset="UTF-8" />    
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

and so on..

回答1:

The xmlns attribute is deprecated in HTML+RDFa 1.1.

You should use the prefix attribute instead:

<html 
  prefix="og: http://ogp.me/ns# 
          fb: http://www.facebook.com/2008/fbml">

resp. if you want to keep the xmlns for XHTML5:

<html 
  xmlns="http://www.w3.org/1999/xhtml"
  prefix="og: http://ogp.me/ns# 
          fb: http://www.facebook.com/2008/fbml">