Search code examples
validationadsamp-html

The attribute 'amp4ads' may not appear in tag 'html'


I was developing AMP Ad as advertiser. I tested the sample amp4ads provided by ampByExample.com (official starter codes)

https://ampbyexample.com/amp-ads/introduction/hello_world/

I found amp4ads is not VALIDATED by official validator (link below)

https://validator.ampproject.org/

here is the sample snippet you can test it on validator

<html ⚡4ads>

<head>

  <meta charset="utf-8">
  <title> Hello World</title>

  <script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script>
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">

  <style amp4ads-boilerplate>body{visibility:hidden}</style>

  <style amp-custom>
    h1 {
      color: red;
    }
  </style>
</head>

<body>

  <h1>Hello World</h1>

</body>
</html>

It throws a lot of errors. Can anyone help me fix this issue, I couldn't find anything related.

Thanks


Solution

  • Unfortunately, validator.ampproject.org does not support AMP Ads. If you open the page in the AMP Playground you'll see that it's valid: https://ampbyexample.com/playground/#url=https%3A%2F%2Fampbyexample.com%2Famp-ads%2Fintroduction%2Fhello_world%2Fsource%2F&runtime=amp4ads.