AMP: Disallowed attribute high
AMP error: "Disallowed attribute or attribute value present in HTML tag"
An AMP page contains a tag or attribute the AMP spec forbids, so it fails validation and loses AMP eligibility in Search.
What you see
The attribute 'onclick' may not appear in tag 'div'. Disallowed attribute or attribute value present in HTML tag.
What’s actually happening
Search Console's AMP report (or the AMP validator at the page URL with #development=1) flags "Disallowed attribute or attribute value present in HTML tag," and the page drops out of AMP results. AMP runs a strict allowlist — every tag and attribute has to be on it. One forbidden attribute invalidates the whole document, so the page falls back to its canonical non-AMP version for AMP-specific Search features. The validator usually names the exact tag and attribute, which is where to start.
Common causes
- Inline event handlers: onclick, onmouseover, onload and friends are banned outright — AMP doesn't allow author JavaScript
- A raw <img>, <video>, or <iframe> instead of the required amp-img, amp-video, amp-iframe components
- A plugin, ad tag, or CDN/optimization layer injecting attributes (data-* hooks, style attributes, tracking params) into the HTML after the fact
- Inline style attributes (style="...") on elements — AMP only allows a single <style amp-custom> block in the head
- A non-AMP value on an otherwise-allowed attribute, e.g. target with an unsupported value, or a custom attribute the spec doesn't recognize
How to fix it
- Get the exact location from the validatorAppend #development=1 to the AMP URL and open the console, or paste the URL into validator.ampproject.org. It prints the line, column, tag, and offending attribute. Fix the named attribute rather than guessing across the template.
- Remove inline JS and replace with AMP componentsStrip every on*="..." handler. For interactivity use amp-bind with the on="tap:..." syntax on AMP elements, amp-carousel for sliders, and amp-analytics for tracking. There is no path to keeping a plain onclick on an AMP page.
- Swap raw media tags for AMP equivalentsReplace <img> with amp-img (with explicit width/height and layout), <iframe> with amp-iframe, <video> with amp-video. These carry their own allowed attribute sets and won't trip the disallowed-attribute check.
- Move inline styles into <style amp-custom>Delete style="..." attributes and put the rules in the single allowed <style amp-custom> block in the head, keeping it under the 75KB limit. Use classes/IDs to target the elements instead.
- Find what's injecting the attributeIf the offending attribute isn't in your source, a plugin, ad script, or proxy is adding it. Disable AMP-incompatible plugins, exclude the AMP template from optimization rewrites, and re-validate after each change to isolate the source.
Stop it recurring
Run the AMP validator in CI against rendered AMP output so a disallowed attribute fails the build instead of reaching Search.
Related errors