AMP HTML Specification
AMP HTML is a subset of HTML for authoring content pages such as news articles in a way that guarantees certain baseline performance characteristics. Being a subset of HTML, it puts some restrictions on the full set of tags and funtionality available through HTML.
The AMP HTML format
AMP HTML documents MUST
- start with the doctype
- contain a top-level
<html ⚡>tag (
<html amp>is accepted as well).
<body>tags (They are optional in HTML).
- contain a
<link rel="canonical" href="/$SOME_URL">tag inside their head that points to the regular HTML version of the AMP HTML document or to itself if no such HTML version exists.
- contain a
<meta charset="utf-8">tag as the first child of their head tag.
- contain a
<meta name="viewport" content="width=device-width,minimum-scale=1">tag inside their head tag. It's also recommended to include
- contain a
<script async src="https://cdn.ampproject.org/v0.js"></script>tag inside their head tag.
- contain the AMP boilerplate code (
head > style[amp-boilerplate]and
noscript > style[amp-boilerplate]) in their head tag.
HTML tags can be used unchanged in AMP HTML. Certain tags have equivalent custom tags (such as
<amp-img>) and other tags are outright prohibited:
|Tag||Status in AMP HTML|
|script||Prohibited unless the type is
|noscript||Allowed. Can be used anywhere in the document. If specified, the content inside the
|form||Allowed. Require including amp-form extension.|
|input elements||Mostly allowed with exception of some input types, namely,
||Required style tag for amp-boilerplate. One additional style tag is allowed in head tag for the purpose of custom styling. This style tag must have the attribute
|svg||Most SVG elements are allowed.|
Attribute names starting with
on (such as
onmouseover) are disallowed in AMP HTML. The attribute with the literal name
on (no suffix) is allowed.
style attribute must not be used.
XML-related attributes, such as
xml:space are disallowed in AMP HTML.
Internal AMP attributes prefixed with
i-amp- are disallowed in AMP HTML.
Usage of the
!important qualifier is not allowed. This is a necessary requirement to enable AMP to enforce its element sizing invariants.
These CSS properties are permanently banned:
The following properties are currently blacklisted due to performance concerns:
AMP only allows transitions and animations of properties that can be GPU accelerated in common browsers. We currently whitelist:
Authors may include stylesheets for custom fonts. The 2 supported methods are link tags pointing to whitelisted font providers and
The following origins are currently allowed for font serving via link tags:
- Fonts.com: https://fast.fonts.net
- Google Fonts: https://fonts.googleapis.com
- Font Awesome: https://maxcdn.bootstrapcdn.com
Currently, the following SVG elements are allowed:
- basics: "g", "glyph", "glyphRef", "image", "marker", "metadata", "path", "solidcolor", "svg", "switch", "view"
- shapes: "circle", "ellipse", "line", "polygon", "polyline", "rect"
- text: "text", "textPath", "tref", "tspan"
- rendering: "clipPath", "filter", "hkern", "linearGradient", "mask", "pattern", "radialGradient", "vkern"
- special: "defs" (all children above are allowed here), "symbol", "use"
- filter: "feColorMatrix", "feComposite", "feGaussianBlur", "feMerge", "feMergeNode", "feOffset", "foreignObject"
- ARIA: "desc", "title"
As well as these attributes:
- "xlink:href": only URIs starting with "#" are allowed