New Facebook like button HTML validation

前端 未结 15 1898
抹茶落季
抹茶落季 2020-12-02 11:34

After adding the new facebook like button on my page, it\'s no longer validates using XHTML strict standard. The two errors I come across are:

  1. All of the
相关标签:
15条回答
  • 2020-12-02 11:46

    RE: Welcho

    Found the script type was causing an error for me (XHTML 1.0 Transitional). Also added for those who may be missing that.

    Your's is the best and easiest to use I have seen online to date. After looking over it again - ha! you're the best :)

    Cheers and thnks :)

    <div id="fb-root"></div>   
    
    <div id="FbCont">
    <script type="text/javascript" 
    src="http://connect.facebook.net/en_US/all.js#appId=XYOURIDXyourapID=1">
    </script>
    <script type="text/javascript">
    <!--//--><![CDATA[//>
    <!--
    var fb = document.createElement('fb:like'); 
    fb.setAttribute("href","http://www.wakawakblahblah.com"); 
    // fb.setAttribute("layout","button_count");
    fb.setAttribute("send","true");
    fb.setAttribute("action","recommended");
    fb.setAttribute("show_faces","false");
    fb.setAttribute("width","280");
    fb.setAttribute("font","trebuchet ms");
    document.getElementById("FbCont").appendChild(fb);
    //--><!]]>
    </script>
    </div>
    
    0 讨论(0)
  • 2020-12-02 11:48

    have you tried to add xmlns:fb="http://www.facebook.com/2008/fbml"?

    0 讨论(0)
  • 2020-12-02 11:49

    starting today you can also use HTML5-compliant markup

    e.g. instead of

    <fb:like href="example.org">
    

    you can do

    <div class="fb-like" data-href="example.org">
    

    Since data-* attributes are valid in HTML5

    0 讨论(0)
  • 2020-12-02 11:50

    Just a follow-up in case anyone uses the comment method. Facebook currently honors comments, so wrapping meta property tags in comments will cause Facebook to ignore them. If you check your pages with the Facebook URL Linter you can see they don't use commented-out meta tags.

    0 讨论(0)
  • Ok, after going over literally hundreds of these posts, I finally found a quick and easy way to get a valid page with a Like button (or any other facebook widget) on it.

    Just a fewlines of code really, take a look at http://www.liormark.com/develop/development-articles/facebook-fbml-w3c-validation-solved

    0 讨论(0)
  • 2020-12-02 11:56

    @Eric I hope you eventually found what you were looking for.

    Twitter integration has its difficulties if you want to empower developers to validate irrespective of XHTML Strict 1.0 or HTML5. Facebook, on the other hand, is down right impossible with its custom FBML tags.

    On our last project my friend Jason and I knew two things for certain:

    1. We were going to validate XHTML Strict 1.0 using Facebook's Like Button
    2. We were not going to add Technical Debt by fudging our DOCTYPE or xmlns

    The solution is to use a flexible, asynchronous JavaScript module. Thankfully, we had some help and guidance along the way: http://techoctave.com/c7/posts/40-xhtml-strict-tweet-button-and-facebook-like-button

    0 讨论(0)
提交回复
热议问题