Skip to content
Login Contact

AMP validation error codes and how to fix them

Each section below describes an AMP validation error code that Marfeel audits can detect on your pages. For each error, you will find the internal code, an explanation when available, and a link to further documentation.

code: amp_analytics_missing

The amp-analytics script is required in the <head> of your AMP pages so that traffic is correctly tracked. Without it, AMP page views will not appear in your analytics.

Read more

code: ATTR_VALUE_REQUIRED_BY_LAYOUT

Read more

code: CDATA_VIOLATES_DENYLIST

Specific CSS data has been denylisted to validate essential CSS AMP rules.

The following is the list of denylisted CSS data (see also disallowed_cdata_regex in the AMP validator spec):

"\.i?-amp-" ("CSS -amp- class name prefix")
"!important"
"charset"
"&#64;import"
"@namespace"
"@document"
"@page"
"@viewport"

Read more

code: CSS_SYNTAX_BAD_URL

Read more

code: CSS_SYNTAX_DISALLOWED_IMPORTANT

Usage of the !important CSS qualifier is not allowed in AMP pages.

Read more

CSS syntax error: disallowed media feature

Section titled “CSS syntax error: disallowed media feature”

code: CSS_SYNTAX_DISALLOWED_MEDIA_FEATURE

Read more

CSS syntax error: EOF in prelude of qualified rule

Section titled “CSS syntax error: EOF in prelude of qualified rule”

code: CSS_SYNTAX_EOF_IN_PRELUDE_OF_QUALIFIED_RULE

End of stylesheet encountered in prelude of a qualified rule.

Read more

code: CSS_SYNTAX_INCOMPLETE_DECLARATION

Read more

code: CSS_SYNTAX_INVALID_AT_RULE

Read more

code: CSS_SYNTAX_INVALID_DECLARATION

Read more

code: DISALLOWED_AMP_DOMAIN

The script tag includes an invalid AMP domain in the src attribute.

Read more

code: DISALLOWED_ATTR

Attributes are allowlisted, so there is no definitive list of all disallowed attributes. To check the supported attributes for each specific tag, search for HTML tag, and then attrs in the AMP validator spec.

In addition to a allowlist of specific attributes for each tag, all AMP tags can use any of the attributes allow-listed under $GLOBAL_ATTRS; all attributes with a prefix of “data-” are also allowlisted.

Read more

code: DISALLOWED_CHILD_TAG_NAME

Read more

code: DISALLOWED_FIRST_CHILD_TAG_NAME

Read more

code: DISALLOWED_MANUFACTURED_BODY

Tag or text which is only allowed inside the body section found outside of the body section.

Read more

code: DISALLOWED_PROPERTY_IN_ATTR_VALUE

This error occurs when the property name inside an attribute is not allowed. The term property in this context means the structured key/value data inside an attribute.

For example, the following would result in an error:

<meta http-equiv="X-UA-Compatible" content="invalidfoo=edge">

It should be: <meta http-equiv="X-UA-Compatible" content="ie=edge">. As another example, in

<meta name="viewport content="width=device-width;minimum-scale=1">, width and minimum-scale are property names.

The following results in a DISALLOWED_PROPERTY_IN_ATTR_VALUE error:

<meta name="viewport content="width=device-width;invalidfoo=1">

Read more

code: DISALLOWED_RELATIVE_URL

Read more

code: DISALLOWED_SCRIPT_TAG

The AMP format does not allow custom JavaScript to be added to pages via the <script> element. Many common uses of JavaScript have AMP HTML library equivalent implementations. See AMP components for the set of components that can be used to enhance AMP HTML pages.

If none of the available components cover your use case, amp-script can be used to run your custom JavaScript.

Read more

code: DISALLOWED_TAG

Tags are allowlisted, so there is no definitive list of all disallowed tags; however, the AMP specification broadly defines the set of disallowed tags.

Read more

code: DISALLOWED_TAG_ANCESTOR

This error occurs when a tag is a descendant of another tag which does not validate. Currently, the only example is a template tag, which may not be nested under another template tag.

Read more

code: DOCUMENT_TOO_COMPLEX

The document is too complex for AMP validation.

Read more

code: DUPLICATE_ATTRIBUTE

Read more

code: DUPLICATE_DIMENSION

Multiple image candidates with the same width or pixel density found.

Read more

code: DUPLICATE_UNIQUE_TAG

This error occurs when exactly one instance of the tag is allowed, and a duplicate is found.

The full list of unique tags is known:

<doctype html>

<html amp>

<head>

<link rel=canonical href=...>

<link rel=amphtml href=...>

<meta charset="utf-8">

<meta viewport>

<style amp-custom>

<style amp-boilerplate>

Read more

code: DUPLICATE_UNIQUE_TAG_WARNING

Found more than once a certain tag supposed to be unique.

Read more

code: EXTENSION_UNUSED

An extension was found on this page, but is unused. Remove this extension to resolve the error.

Some extensions examples are ‘amp-script’, ‘amp-analytics’, ‘amp-consent’, ‘amp-geo’, ‘amp-image-lightbox’ or ‘amp-video-docking’.

Read more

code: FAILED_VALIDATION

The system has not been able to validate the information in these URLs.

Read more

code: GENERAL_DISALLOWED_TAG

Found a tag that is disallowed except in specific forms.

Read more

code: INCORRECT_MIN_NUM_CHILD_TAGS

Read more

code: INCORRECT_NUM_CHILD_TAGS

Read more

code: INLINE_STYLE_TOO_LONG

Found a tag with inline style over the size limit in bytes.

Read more

code: INVALID_ATTR_VALUE

This error indicates that an HTML tag has an attribute with an allowed name, but not an allowed value. One common trigger is invalid URL values. All URL values (in href and src attributes) must match one of the possible attribute values defined in the AMP specification.

IMPORTANT: Many URL values in AMP require HTTPS. If you are getting this error, and are not sure why, check the relevant AMP tag’s specification to see if the attribute requires HTTPS.

Read more

code: INVALID_DOCTYPE_HTML

Invalid or missing doctype declaration. Should be ‘!doctype html’.

Read more

code: INVALID_JSON_CDATA

The script tag contains invalid JSON that cannot be parsed.

Read more

code: INVALID_URL

This error occurs when an attribute has a URL, but the URL is invalid.

Read more

code: INVALID_URL_PROTOCOL

This error occurs for tags that have an href or src that must be set to certain protocols. For example, many tags require HTTPS.

Read more

code: MANDATORY_ATTR_MISSING

Mandatory attributes for AMP tags are defined within the AMP validator spec. Search for the tag, view the listed attributes, and check for mandatory: true. Mandatory attributes for each AMP tag are also listed within the tag’s specification.

Read more

code: MANDATORY_LAST_CHILD_TAG

Read more

code: MANDATORY_ONEOF_ATTR_MISSING

A tag was found missing a mandatory attribute.

Read more

code: MANDATORY_REFERENCE_POINT_MISSING

Read more

code: MANDATORY_TAG_ANCESTOR

Mandatory descendants are defined in the AMP validator specification as mandatory_ancestor.

The error occurs when the following tags are missing their mandatory_ancestor (tag, ancestor):

img must be a descendant of noscript.

video must be a descendant of noscript.

audio must be a descendant of noscript.

noscript must be a descendant of body.

Read more

code: MANDATORY_TAG_ANCESTOR_WITH_HINT

The error occurs when one of the following tags is found in the AMP document, and is not properly nested in its mandatory parent:

img is not within noscript parent.

video is not within noscript parent.

audio is not within noscript parent.

noscript is not within body parent.

Read more

code: MANDATORY_TAG_MISSING

The following tags must be present in all AMP documents:

<!doctype html>

<html amp> or <html ⚡>

<head>

<link rel="canonical" href="$SOME_URL">

<meta charset="utf-8">

<meta name="viewport" content="...">

<style amp-boilerplate>

<body>

These mandatory tags include a mandatory: true field in the AMP validator spec; they are also referenced in the AMP specification.

Read more

code: MISSING_LAYOUT_ATTRIBUTES

Read more

code: MISSING_REQUIRED_EXTENSION

Read more

code: MISSING_URL

This error occurs when an attribute that requires a URL is missing it, for example, an empty href or src attribute.

Read more

code: REDIRECTED

Read more

code: REDIRECTED_ARTICLE

Read more

code: SERVER_ERROR

Read more

code: STYLESHEET_AND_INLINE_STYLE_TOO_LONG

Read more

code: STYLESHEET_TOO_LONG

The AMP validator throws this error when it measures the size of the styles content within <style amp-custom> to exceed the 75,000 bytes limit.

Read more

code: TAG_EXCLUDED_BY_TAG

Found a tag excluded by the presence of a second tag.

Read more

code: TAG_NOT_ALLOWED_TO_HAVE_SIBLINGS

Read more

code: TAG_REQUIRED_BY_MISSING

The validator throws the TAG_REQUIRED_BY_MISSING error when it finds an extended component in the AMP document, but does not find its equivalent <script>.

Extended components must be explicitly included in the AMP document as custom elements. To fix these errors, navigate to the extended component’s reference page, copy its required script, and paste it into the AMP document <head>.

Read more

code: VALUE_SET_MISMATCH

Found attribute containing a value not matching any other tag in the page.

Read more

code: WARNING_TAG_REQUIRED_BY_MISSING

This error happens when a tag is required by some element, but could not be found.

Read more

code: WRONG_PARENT_TAG

Specific tags require an immediate parent (as opposed to distant ancestor). The following lists the required parent for specific tags (tag, parent):

  • !doctype requires parent tag root.
  • html requires parent tag !doctype.
  • head requires parent tag html.
  • body requires parent tag html.
  • link requires parent tag head.
  • meta requires parent tag head.
  • style amp-custom requires parent tag head.
  • style requires parent tag boilerplate (noscript).
  • noscript requires parent tag head.
  • script requires parent tag head.
  • source requires a media tag (amp-audio, amp-video, etc.).

Read more