So I've been playing with Google's +1 button trying to get it on my website, but it's not W3C compliant.
Here's the code:
<!-- Place this tag in your head or just before your close body tag --> <script type="text/javascript" src="http://apis.google.com/js/plusone.js"> {lang: 'en-GB'} </script> <!-- Place this tag where you want the +1 button to render --> <g:plusone size="medium" href="http://www.example.org"></g:plusone>
Does anyone know why this happens and how to make this compliant? Thanks
EDIT: To get this to pass through the validation, I wrote an article on my website.
If Google can crawl and render a page Google will rank the page appropriately based on how relevant it is to the query. Invalid HTML can on the other hand can cause search engines problems. QUOTE: “ In general, the W3C validation is something that we do not use when it comes to search.
as the current implementation of ChromeDriver requests a W3C-compliant session to the client. However, this error message implies that the ChromeDriver was unable to invoke a non W3C standard command while in W3C mode while initiating/spawning a new WebBrowser i.e. Chrome Browser session.
Till ChromeDriver v74.x, Chrome and ChromeDriver combo was running in w3c mode by default but there was bug with in the chromedriver/server/http_handler.cc. As per the details in goog:chromeOptions.w3c=false doesn't work for POST request with empty body:
It should be noted that W3C WebDriver specification doesn't forbid the use of 'displayed' endpoint and this feature is actively used in some APIs. As Is Element Displayed command is not part of W3C spec, but is still used by some APIs, and its functionality can be difficult to replicate in those APIs.
Does anyone know why this happens?
Because Google designed it to use tag soup instead of HTML
How to make this compliant?
The documentation has alternative markup that is valid under the draft HTML 5 specification:
<div class="g-plusone" data-size="standard" data-count="true"></div>
If you want it to work with HTML 4.x or XHTML 1.x then you might be out of luck (although you might be able to add the non-compliant markup using JS, but that would just be a hack to conceal it from validation and not at all in the spirit of valid markup)
Insert this code in the header:
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"> {lang:'en', parsetags:'explicit'} </script>
Then insert this code where you want the button:
<div id="plusone-div" class="plusone"></div> <script type="text/javascript"> gapi.plusone.render('plusone-div',{"size": "small", "count": "true"}); </script>
The complete answer can be found here (in French)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With