Clicky

  1. Home
  2. Troubleshooting
  3. AMP Validation Errors and Solutions – Troubleshooting Google AMP Search Console

AMP Validation Errors and Solutions – Troubleshooting Google AMP Search Console

Google AMP as you know is the latest technology to help accelerate the mobile pages, but it has strict standards as to what you can do, just like any good technology.

AMP does not stop you from using your creativity. You can literally do anything you want on top of AMP but it has to be in a right way or else it won’t pass the AMP validation.

Better Validation has been our number one priority while developing AMPforWP plugin, it provides even better validation than the AMP by Automattic plugin.

Even if AMPforWP has the best validation support, Google search console will still report validation errors in Accelerated Mobile Pages section and there could be hundreds of reasons behind these error reports.

I was trying my best to help everyone by fixing their validation issues manually in search console. I must have validated hundreds of AMP websites validated, I decided to make a troubleshooting guide which will help not only our users but to the whole AMP community!

Things to remember before Jumping

  1. Real Examples: I’m posting these solutions and problems while debugging, so the code that you will see is from one of the users of the plugin. It is possible that the solution is either same or similar to the one provided in the guide.
  2. Always under progress: We’re constantly updating this troubleshooting guide as we find new solutions.
  3. It’s gonna be fine: AMP troubleshooting can be overwhelming. So, if you find yourself lost in this article, that’s perfectly normal. Just spend some time and it will help you understand the concept.
  4. Get involved: Please get involved with us from the comments section.

Divide the Errors into Categories:

error into categories

By default, GSC (Google Search Console) breaks down the errors into 10 categories.

  1. Prohibited or invalid use of HTML Tag
  2. AMP markup missing or incorrect
  3. Prohibited HTML Tag with AMP equivalent
  4. User-authored JavaScript found on page
  5. Invalid CSS stylesheet
  6. Major content mismatch
  7. Use of deprecated tags or attributes
  8. Minor content mismatch
  9. Invalid structured data element
  10. Add AMP structured data, if supported

We will also break the errors and their solutions into these categories.

1. Prohibited or invalid use of HTML Tag

  • 1) The attribute ‘xml:lang’ may not appear in tag ‘span’.

This means that there is an attribute in the HTML tags, which are not allowed by AMP. When we check the source code of the AMP version, we found this:

Invalid use html tags

Solution: There are two ways of fixing this: One is that you go to your WordPress content editor, find this and remove this tag. If you want this tag then the second solution is that you use Content overwrite feature to serve different content to AMP version.

  • 2) Multiple Errors in Categories and Tags Pages

The attribute 'prefix' may not appear in tag 'html ⚡ for top-level html'.
The mandatory attribute 'amp-custom' is missing in tag 'style amp-custom'.
Tag or text which is only allowed inside the body section found outside of the body section.
The attribute 'style' may not appear in tag 'img'.
The attribute 'type' may not appear in tag 'noscript > style[amp-boilerplate] - old variant'.

Solution: If you are getting multiple errors in just category and tags pages, then you don’t need to worry about this because we do not have AMP on categories and tags. It will probably take a few weeks until Google reindexes all the pages properly.

  • 3) The attribute ‘target’ may not appear in tag ‘button’.

There is a target attribute in the AMP HTML which not allowed by the validation. When we run it with the AMP validator, we found this:

Traget Attribute

Solution: There are two ways of fixing this: One is that you go to your WordPress content editor, find this and remove this tag. If you want this tag then the second solution is that you use Content overwrite feature to serve different content to AMP version.

Back to you

Please share your issues in the below comments, we will try our best to help you provide solutions to them.

History: Last Updated: 12 Jan 2017

We are always updating this guide with better solutions as we find them.

These are common AMP errors reported in Google Search Console. Hope you have solved your error, if not then let us know what is the error you are facing in the comment section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on April 4, 2018

    Are you still looking for a solution?

    Then fill out the below form and we will reach out to you within a few hours.

    Was this article helpful?

    Related Articles

    Comments

    1. Dear Team,
      I am getting the error “The text inside tag ‘style amp-custom’ contains ‘CSS !important’, which is disallowed.”
      How do I fix it?

      I’ll appreciate your response.

      1. Hi Sydney Clinton,

        In AMP ‘!important’ is not allowed in CSS please remove it and your issue will remove it.

        1. Hi Sonali,
          What are the steps to removing the text? I don’t know my around CSS.

          Thanks

    2. Hi Sonali,
      What are the steps to removing the text? I don’t know my way around CSS.

      Thanks

      1. if you want to remove the css important then
        1. go to your plugin editor.
        2. select amp
        3. choose stylesheet to edit
        4. use control f and type in important and hit enter
        5. it will appear and then you can remove it
        I got this error on my site TopHits.ng but fixed.

        1. Hi TopHits.ng,

          We have checked your website and found that it’s valid and also if you apply CSS !important in custom CSS it will be removed automatically.

    3. I have following errors

      Tag or text which is only allowed inside the body section found outside of the body section. DISALLOWED_HTML
      line 1, column 3131

      The tag ‘BODY’ appears more than once in the document. MANDATORY_AMP_TAG_MISSING_OR_INCORRECT
      line 1, column 3131

      The parent tag of tag ‘amp-position-observer extension .js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 3428

      The parent tag of tag ‘amp-animation extension .js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 3556

      The parent tag of tag ‘amp-form extension .js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 3668

      The parent tag of tag ‘amp-analytics extension .js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 3770

      The parent tag of tag ‘amp-user-notification extension .js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 3882

      The parent tag of tag ‘amphtml engine v0.js script’ is ‘body’, but it can only be ‘head’. CUSTOM_JAVASCRIPT_DISALLOWED
      line 1, column 4010

      The parent tag of tag ‘style amp-custom’ is ‘body’, but it can only be ‘head’. DISALLOWED_HTML
      line 1, column 4073

      The tag ‘noscript > style[amp-boilerplate]’ may only appear as a descendant of tag ‘head’. DISALLOWED_HTML
      line 1, column 4712

      The parent tag of tag ‘style amp-custom’ is ‘body’, but it can only be ‘head’. DISALLOWED_HTML
      line 1, column 4902

      The mandatory tag ‘head > style[amp-boilerplate]’ is missing or incorrect. MANDATORY_AMP_TAG_MISSING_OR_INCORRECT
      line 7, column 42

      The mandatory tag ‘noscript enclosure for boilerplate’ is missing or incorrect. MANDATORY_AMP_TAG_MISSING_OR_INCORRECT
      line 7, column 42

    4. Hi – I started getting a “Custom JavaScript is not allowed” error in Search Console on my AMP pages, starting August 8th. I’ve really been struggling to find a solution online anywhere . . . Considering it was close to the Aug 6th AMP release, I was wondering if you had any suggestions. Any help would be appreciated!
      Here’s one of the impacted sites: https://saffordins.com/blog/massachusetts-short-term-rental-insurance/amp

      1. Hi Greg Safford,

        We have checked your website and found that you are adding “google_analytics_auto.js” file in AMP and javaScript in not allow that’s the reason you are getting this error. Are you manually adding it?

        1. I don’t believe I’m adding it manually. I thought maybe an SEOPress plugin was injecting it but I’ve turned that off and am still seeing the issue. Do you have any idea where it may be coming from? I don’t have an unusual setup so I thought you might have run across this before.

          1. Greg can you soul your website issus about ”
            Custom JavaScript is not allowed” if Yes please tell me how to solve this.

            Any one who help me about error.

            my site – https://www.hindimepadhe.net

            1. Hi Bunty shirsath,

              I have checked your website but I have unable to any javascript error will you please provide us exact URL where you are having error so that we can check and get back to you.

    5. Hi

      I found a lot of errors on the Google console amp with information:

      The attribute ‘menu-item-type-taxonomy’ may not appear in tag ‘li’.

      1. Hi Reza,

        Could you please tell us which menu plugin are you using? will you please provide us exact URL where you are having error so that we can check and get back to you.

    6. AMP HTML Tag has an invalid layout specified by its attributes.

      I got this error in google search console

      what is the solution for this error?

      1. Hi Dinesh more,

        Will you please provide us exact URL where you are having an error so that we can check and get back to you.

    7. I have this error in google search console. How do I solve it?
      AMP HTML Tag has an invalid layout specified by its attributes.

      1. Hi Tariq Khan,

        Will you please provide us exact URL where you are having an issue so that we can check and fix it immediately.

    8. The attribute ‘autocorrect’ may not appear in tag ‘input’. Validation Error

      1. Hi Rajiv Sinha,

        Will you please provide us exact URL where you are having an issue so that we can check and fix it immediately.

          1. Hi Rajiv Ranjan Sinha,

            Sorry for the inconvenience this error will come on AMP comment so will you please contact our technical team from here – https://ampforwp.com/support/ and I am sure there will help you to fix this issue,

    Leave a Comment