W3C Markup Validation error

Yes, that solved that problem. Now though the validator has revealed a few more - 12, eight of which are related to google ads scripts. Is there a fix for those or do I just have to settle for invalid code because of them?

For the Google Ads, where you have async="", remove the =""… It is just async.

At least that is what I think is correct. Let us know…

The google script code is already correct in that regards, so here are the errors as listed by the validator -

This script -

<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- first --> <ins class="adsbygoogle" style="display:inline-block;width:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="4228312577"> </ins> <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

results in these errors -

 there is no attribute "ASYNC"
	<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js…

 required attribute "TYPE" not specified
…agead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- first -->

 there is no attribute "DATA-AD-CLIENT"
…th:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="…

there is no attribute "DATA-AD-SLOT"
…ight:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="4228312577">

required attribute "TYPE" not specified
	<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

and this script -


	<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- third -->
	<ins class="adsbygoogle" style="display:inline-block;width:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="1317251778"></ins>
	<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>	

results in these errors -

[code]
“ASYNC” is not a member of a group specified for any attribute

required attribute “TYPE” not specified
[/code]

I guess, correct me if I am wrong, I can simply add type="" to each to clear that message and remove the async="" to clear that message? Or will that break the scripts?

Well, I said, there is NO async="" That would make it an argument. “async” is an option.
It should mean that the works both ways. Just remove the ="" after it and retry it.

I bet that will fix a lot of the errors. If not I will look at it again…

Here is a link… Look near the bottom at the SYNTAX … NO =""

Hope this helps… http://www.w3schools.com/tags/att_script_async.asp

The errors have been reduced to just 3 different errors in one script and 1 error in the second script.

This is interesting - script 1 has these errors -
“ASYNC” is not a member of a group specified for any attribute (for both scripts)
there is no attribute “DATA-AD-CLIENT” (in both scripts but errors only in script 1)
there is no attribute “DATA-AD-SLOT” (in both scripts but errors only in script 1)

And in script 2 the only error is -
“ASYNC” is not a member of a group specified for any attribute

I find this interesting because the two scripts are identical except for the data for the attribute data-ad-slot. The validator claims that it is not a vaild attribute in script 1, but apparently it’s valid for script 2.
In the two scripts they have slightly different data assigned in that attribute.

The validator claims that data-ad-client is not valid in script 1 but apparently it’s valid for script 2.
In the two scripts these attributes are identical.

I cleared the other errors by adding in type=“text/javascript” to the sections.

Well, per Google’s site, this is a sample of the script needed:
[php]



[/php]
So, as you see, there is NO “type” argument in it.
Your version is like this:
[php]

<ins class="adsbygoogle" style="display:inline-block;width:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="1317251778"></ins>
<script language="JavaScript" type="text/javascript">(adsbygoogle = window.adsbygoogle || []).push({});</script>

[/php]
So yours is quite different than their sample. Not sure what to say. I do not really use these ads.
Here is where I read this: https://support.google.com/adsense/answer/3221666?hl=en
Hope that helps you somehow…

Thanks for the info. comparing the two -
my version of the script -

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type=""></script> <ins class="adsbygoogle" style="display:inline-block;width:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="4228312577"></ins> <script language="JavaScript" type="text/javascript">(adsbygoogle = window.adsbygoogle || []).push({});</script>
google version of the script -

<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" data-ad-slot="6440411535"></ins> <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

As you can see the differences are minor. I added the type attribute and that relevant error went away. Of the two scripts I have in my site only script 1 causes errors. Script 2 is identical to script one except for the data for attribute data-ad-slot.

Why #1 gets errors and #2 doesn’t is a mystery.

Script #2 for comparison purposes -

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type=""></script> <ins class="adsbygoogle" style="display:inline-block;width:120px;height:600px" data-ad-client="ca-pub-1823930734785601" data-ad-slot="1317251778"></ins> <script language="JavaScript" type="text/javascript">(adsbygoogle = window.adsbygoogle || []).push({});</script>

Oh, and in the link you provided to the W3C about the async - this is from that page -
"
In XHTML, attribute minimization is forbidden, and the async attribute must be defined as .
"
so even though they say it must be defined that way it works without the =“async” part.

Well, again, theirs do NOT have the TYPE= in it.

So, yours is totally different because the selects the default “TYPE” of the script and that is NOT a google-ad type.

Try it without the TYPE="" in it…

Without the type="" attribute the validator throws up errors -

required attribute “TYPE” not specified

<script language="JavaScript">(adsbygoogle = window.adsbygoogle || []).push({}…

two errors for each of the scripts.

You do not need it on the first one.

The one with “PUSH” in it is javascript. So, it has to have the type=javascript.

Yikes, this is tricky…

Well, just to make sure nothing in the code was mess up on my side I went back to my adsense account and grabbed the original code, and am back to the original 8 errors for the two ads.

These are from the W3C -

 Error Line 104, Column 15: "ASYNC" is not a member of a group specified for any attribute

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></…

✉
Error Line 104, Column 77: required attribute "TYPE" not specified

… async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

✉

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Error Line 108, Column 21: there is no attribute "DATA-AD-CLIENT"

     data-ad-client="ca-pub-1823930734785601"

✉

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
Error Line 109, Column 19: there is no attribute "DATA-AD-SLOT"

     data-ad-slot="4228312577"></ins>

✉

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
Error Line 110, Column 8: required attribute "TYPE" not specified

<script>

✉

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Error Line 130, Column 15: "ASYNC" is not a member of a group specified for any attribute

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></…

✉
Error Line 130, Column 77: required attribute "TYPE" not specified

… async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

✉

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

Hmmm, lots of reading…

Try it this way…

[php]

[/php]

This was from Google’s site. A sample with your numbers in it. A couple small changes.
Not sure if it will work, but, try it and let me know…

Also, Google is set up to help you with this.

You have to open an error report…

I think the link is: https://productforums.google.com/forum/#!newtopic/adsense

You can plug in your code and give them your test address and they will help you going by what I read.

But, I think this last version might work as it came from Google’s forum… Let me know…

Hi, thanks for the code, but no change at all in the error messages. I will post a message on the adsense forum also. I also found that just a while ago.

Well, I posted a message on the google forum, the did a search and found a post by a person with the same problem. He posted his code which did pass validation. He used an older version of the script and plugged in the new …pub and …slot numbers and it works. I did that, and no more errors. Now to verify that the ads change as expected.

Here is the code used -

[code]

[/code]

Wow, I saw that on the site but it said it was old code, so didn’t think of sending on to you.

Really cool that you figured it out. Hope it works correctly now.

Heee, I will be glad to close this topic… Ha! Just joking…

Let us know if it works. Glad for you pal !

So it appears that the ‘old’ code that they guy posted and I am using does not work in IE10. But for me that doesn’t matter, and for the majority of my site visitors it doesn’t matter, only the minority of users are using IE. Also, it appears that maybe it is not updating the ads. Maybe another day or two will prove that right or wrong, or maybe a reboot, or closing/reopening my browser (which I don’t do too often).

At any rate, a bit more testing is needed before I can say it is fixed.

As for the adsense forums, so far one response, and it is no help -
“You are allowed to make minor adjustments to the code if the kind of html you are using does not pass w3c standards.”

I really hate that kind of reply on forums. Why bother to say anything at all.

I bit the newer code is the way to go if it works okay. And, just forget the validator for that one item.

Or, I wonder if W3 has any comments on it. I will look around later today on that thought…

But, hope it works ad-wise so you can get er done ! Later…

Yep, I’m thinking the same - just use the code google provides and not worry about the W3C validation since it is only google ads and not my coding.

Sponsor our Newsletter | Privacy Policy | Terms of Service