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.
”amp-analytics” not found
Section titled “”amp-analytics” not found”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.
Attribute value required by layout
Section titled “Attribute value required by layout”code: ATTR_VALUE_REQUIRED_BY_LAYOUT
Disallowed text inside tag
Section titled “Disallowed text inside tag”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""@import""@namespace""@document""@page""@viewport"CSS syntax error: bad URL
Section titled “CSS syntax error: bad URL”code: CSS_SYNTAX_BAD_URL
Important CSS disallowed syntax
Section titled “Important CSS disallowed syntax”code: CSS_SYNTAX_DISALLOWED_IMPORTANT
Usage of the !important CSS qualifier is not allowed in AMP pages.
CSS syntax error: disallowed media feature
Section titled “CSS syntax error: disallowed media feature”code: CSS_SYNTAX_DISALLOWED_MEDIA_FEATURE
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.
CSS syntax error: incomplete declaration
Section titled “CSS syntax error: incomplete declaration”code: CSS_SYNTAX_INCOMPLETE_DECLARATION
CSS syntax error: invalid at rule
Section titled “CSS syntax error: invalid at rule”code: CSS_SYNTAX_INVALID_AT_RULE
CSS syntax error: invalid declaration
Section titled “CSS syntax error: invalid declaration”code: CSS_SYNTAX_INVALID_DECLARATION
Disallowed AMP domain
Section titled “Disallowed AMP domain”code: DISALLOWED_AMP_DOMAIN
The script tag includes an invalid AMP domain in the src attribute.
Disallowed attribute
Section titled “Disallowed attribute”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.
Disallowed child tag name
Section titled “Disallowed child tag name”code: DISALLOWED_CHILD_TAG_NAME
Disallowed first child tag name
Section titled “Disallowed first child tag name”code: DISALLOWED_FIRST_CHILD_TAG_NAME
Disallowed manufactured body
Section titled “Disallowed manufactured body”code: DISALLOWED_MANUFACTURED_BODY
Tag or text which is only allowed inside the body section found outside of the body section.
Disallowed property in attribute value
Section titled “Disallowed property in attribute value”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">
Disallowed relative URL
Section titled “Disallowed relative URL”code: DISALLOWED_RELATIVE_URL
Disallowed script tag
Section titled “Disallowed script tag”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.
Disallowed tag
Section titled “Disallowed tag”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.
Disallowed tag ancestor
Section titled “Disallowed tag ancestor”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.
Document too complex
Section titled “Document too complex”code: DOCUMENT_TOO_COMPLEX
The document is too complex for AMP validation.
Duplicate attribute
Section titled “Duplicate attribute”code: DUPLICATE_ATTRIBUTE
Image duplicate for same dimension
Section titled “Image duplicate for same dimension”code: DUPLICATE_DIMENSION
Multiple image candidates with the same width or pixel density found.
Duplicate unique tag
Section titled “Duplicate unique tag”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>
Duplicate unique tag warning
Section titled “Duplicate unique tag warning”code: DUPLICATE_UNIQUE_TAG_WARNING
Found more than once a certain tag supposed to be unique.
Extension unused
Section titled “Extension unused”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’.
Validation was not possible
Section titled “Validation was not possible”code: FAILED_VALIDATION
The system has not been able to validate the information in these URLs.
General disallowed tag
Section titled “General disallowed tag”code: GENERAL_DISALLOWED_TAG
Found a tag that is disallowed except in specific forms.
Incorrect minimum number of child tags
Section titled “Incorrect minimum number of child tags”code: INCORRECT_MIN_NUM_CHILD_TAGS
Incorrect number of child tags
Section titled “Incorrect number of child tags”code: INCORRECT_NUM_CHILD_TAGS
Inline style too long
Section titled “Inline style too long”code: INLINE_STYLE_TOO_LONG
Found a tag with inline style over the size limit in bytes.
Invalid attribute value
Section titled “Invalid attribute value”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.
Invalid doctype HTML
Section titled “Invalid doctype HTML”code: INVALID_DOCTYPE_HTML
Invalid or missing doctype declaration. Should be ‘!doctype html’.
Invalid JSON
Section titled “Invalid JSON”code: INVALID_JSON_CDATA
The script tag contains invalid JSON that cannot be parsed.
Invalid URL
Section titled “Invalid URL”code: INVALID_URL
This error occurs when an attribute has a URL, but the URL is invalid.
Invalid URL protocol
Section titled “Invalid URL protocol”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.
Mandatory attribute missing
Section titled “Mandatory attribute missing”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.
Mandatory last child tag
Section titled “Mandatory last child tag”code: MANDATORY_LAST_CHILD_TAG
Mandatory one-of attribute missing
Section titled “Mandatory one-of attribute missing”code: MANDATORY_ONEOF_ATTR_MISSING
A tag was found missing a mandatory attribute.
Mandatory reference point missing
Section titled “Mandatory reference point missing”code: MANDATORY_REFERENCE_POINT_MISSING
Mandatory tag ancestor
Section titled “Mandatory tag ancestor”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.
Mandatory tag ancestor with hint
Section titled “Mandatory tag ancestor with hint”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.
Mandatory tag missing
Section titled “Mandatory tag missing”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.
Missing layout properties
Section titled “Missing layout properties”code: MISSING_LAYOUT_ATTRIBUTES
Missing required extension
Section titled “Missing required extension”code: MISSING_REQUIRED_EXTENSION
Missing URL
Section titled “Missing URL”code: MISSING_URL
This error occurs when an attribute that requires a URL is missing it, for example, an empty href or src attribute.
Server returned a redirection
Section titled “Server returned a redirection”code: REDIRECTED
Redirected article
Section titled “Redirected article”code: REDIRECTED_ARTICLE
Server returned an error response
Section titled “Server returned an error response”code: SERVER_ERROR
Stylesheet and inline style too long
Section titled “Stylesheet and inline style too long”code: STYLESHEET_AND_INLINE_STYLE_TOO_LONG
Stylesheet too long
Section titled “Stylesheet too long”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.
Tag excluded by tag
Section titled “Tag excluded by tag”code: TAG_EXCLUDED_BY_TAG
Found a tag excluded by the presence of a second tag.
Tag not allowed to have siblings
Section titled “Tag not allowed to have siblings”code: TAG_NOT_ALLOWED_TO_HAVE_SIBLINGS
Tag required by another tag is missing
Section titled “Tag required by another tag is missing”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>.
Value set mismatch
Section titled “Value set mismatch”code: VALUE_SET_MISMATCH
Found attribute containing a value not matching any other tag in the page.
Tag required but missing
Section titled “Tag required but missing”code: WARNING_TAG_REQUIRED_BY_MISSING
This error happens when a tag is required by some element, but could not be found.
Wrong parent tag
Section titled “Wrong parent tag”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):
!doctyperequires parent tagroot.htmlrequires parent tag!doctype.headrequires parent taghtml.bodyrequires parent taghtml.linkrequires parent taghead.metarequires parent taghead.style amp-customrequires parent taghead.stylerequires parent tagboilerplate(noscript).noscriptrequires parent taghead.scriptrequires parent taghead.sourcerequires a media tag (amp-audio,amp-video, etc.).