Google +1 Button not W3C compliant Google +1 Button not W3C compliant javascript javascript

Google +1 Button not W3C compliant


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)


I'm guessing you're trying to validate XHTML. The closest you're going to come is to successfully validating is by defining the "g" namespace on your element by adding this:

xmlns:g="http://base.google.com/ns/1.0"

i.e.,

<html xmlns:g="http://base.google.com/ns/1.0"> ... </html>