Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google +1 Button not W3C compliant

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.

like image 920
ingh.am Avatar asked Jun 02 '11 16:06

ingh.am


People also ask

Does W3C validation affect search engines?

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.

Why am I getting a W3C-compliant session error in chromedriver?

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.

Is Chrome running in W3C mode by default?

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:

Is the 'displayed' endpoint part of the W3C specification?

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.


2 Answers

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)

like image 184
Quentin Avatar answered Oct 03 '22 22:10

Quentin


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)

like image 31
Gilbou Avatar answered Oct 03 '22 22:10

Gilbou