List of important custom and in-built AMP tags


amp-img is use as replacment of HTML img tag. amp-img tag effectively manage image resource at runtime. It uses lazy load to reduce page load time.

To use amp-img need to specify width and height, src attriburtes. It also support three optional attributes srcset, alt, attribution.

  • src – url of image need to display.
  • srcset – for retine ready images. We can provide different image for devices varying pixel ratio.
  • attribution – to set attribution text of the image.

To set image to responsive use layout attribute and set it value responsive.

Example of amp-img
<amp-img src=\"/img/amp.jpg\"
srcset=\"/img/amp.jpg 1080w, /img/amp-900.jpg 900w, /img/amp-800.jpg 800w,
/img/amp-700.jpg 700w, /img/amp-600.jpg 600w, /img/amp-500.jpg 500w, /img/amp-400.jpg 400w,
/img/amp-300.jpg 300w, /img/amp-200.jpg 200w, /img/amp-100.jpg 100w\"
alt=\"an image\"></amp-img>

amp-img is builtin tag and imported via the AMP js.


amp-video is replacement of Html Video tag. It also lazy load video at runtime.

To use amp-video you must specify width, height and src attributes. It also support some more optional attributes poster, autoplay, controls, loop, muted. It also accept three unique HTML child nodes tag, placeholder before video start, and fallback.

Example of amp-video
<amp-video width=400 height=300 src=\"\"
  <div fallback>
    <p>Your browser doesn’t support HTML5 video</p>
  <source type=\"video/mp4\" src=\"foo.mp4\">
  <source type=\"video/webm\" src=\"foo.webm\">

amp-video is in-builtn tag and imported via the AMP js.


amp-audio is replacement of HTML audio tag. It is use to embed audio file in amp pages.

To use amp-audio you must specify src, width and height attributes, amp-audio also have three more optional attribute autoplay, loop and muted.

  • src – audio file url.
  • autoplay – It will autoplay animated image.
  • loop – it will auto loop audio.
  • muted – muted audio by default.
Example of amp-audio
 <amp-audio width=\"400\" height=\"300\" src=\"\">
  <div fallback>
    <p>Your browser doesn’t support HTML5 audio</p>
  <source type=\"audio/mpeg\" src=\"foo.mp3\">
  <source type=\"audio/ogg\" src=\"foo.ogg\">

To use amp-audio you have to include below script in <head> section

 <script async custom-element=\"amp-audio\" src=\"\"></script>


amp-accordion is use to implement accordion in amp pages. Accordion is mostly use in faq pages.

Amp-accordion can have one or more first child node <section> and each <section>contain 2 child node first one is heading and second node is content and clicking heading it will toggle display of content.

Below example of amp-accordion
  <section expanded>
    <h2>Section 1</h2>
    <p>Bunch of awesome content</p>
    <h2>Section 2</h2>
    <div>Bunch of awesome content</div>
    <h2>Section 3</h2>
    <amp-img src=\"/awesome.png\" width=\"300\" height=\"300\"></amp-img>

amp-accordion also provides below attributes

  • disable-session-states – to disable preserving the collapsed/expanded state of the amp-accordion element
  • expanded – to set on any <section> expanded on page load.

To use amp-accordion you have to include below script in <head> section

<script async custom-element=\"amp-accordion\" src=\"\"></script>


amp-carousel tag to display content boxes horizontally. A carousel is set of number of items with optional navigational arrow. The carousel move items if user swipe, or use arrow key or use navigation arrow.

To use amp-carousel you must specify height attribute, it also provide more optional attributes controls, type, loop, autoplay, delay.

  • controls – to display navigation arrow
  • type – by default its value is carousel all slides are shown and scrollable. If type value is Slides, it will display singe silde at a time. With type slides you can use three more attribute loop, autoplay, delay.
Example of carousel
 <amp-carousel width=300 height=400>
  <amp-img src=\"my-img1.png\" width=300 height=400></amp-img>
  <amp-img src=\"my-img2.png\" width=300 height=400></amp-img>
  <amp-img src=\"my-img3.png\" width=300 height=400></amp-img>

To use amp-audio you have to include below script in <head> section

<script async custom-element=\"amp-carousel\" src=\"\"></script>


amp-lightbox tag to implement light box interface. amp-lightbox will have to define child node
to display child node content in lightbox on tap or click event.

Example of amp-lightbox
 <button on=\"tap:my-lightbox\">Open lightbox</button>
<amp-lightbox id=\"my-lightbox\" layout=\"nodisplay\">
  <div class=\"lightbox\">
    <amp-img src=\"my-full-image.jpg\" width=300 height=800 on=\"tap:my-lightbox.close\">

To use amp-lightbox you have to include below script in <head> section

<script async custom-element=\"amp-lightbox\" src=\"\"></script>


amp-ad is use to display ads. amp-embed is an alias of the amp-ad and use amp-embed when logically more accurate. Your ad javascript will not run inside your amp page, AMP will loads an iframe on runtime and execute ad javascript inside iframe sandbox.

To use amp-ad you need to specify type, width, height attributes. Type is name of ad network to which your ad belong. All data-* attributes also depend on type of network.

Below example amp-ad of for different type of network

 <amp-ad width=300 height=250

<amp-ad width=320 height=140

<amp-embed width=400 height=300
    data-placement=\"Below Article Thumbnails\">

To use amp-ad you have to include below script in <head> section

<script async custom-element=\"amp-ad\" src=\"\"></script>


amp-analytics is use to collect analytics data from an AMP page. Currently amp-analytics support below events:

  • Pageview
  • Anchor Clicks
  • Timer
  • Scrolling
  • AMP Carousel changes

To send data to analytcis server you need to specify json configuration object inside amp-analytics tag. Some vendor provide pre configure json configuration object. With type attribute you can set vendor and their json object.

Example for amp-analytics
<amp-analytics type=”abc”>
<script type=\"application/json\">

To use amp-analytics you have to include below script in <head> section

<script async custom-element=\"amp-analytics\" src=\"\"></script>


amp-iframe to display an iframe in AMP pages. amp-iframe is more secure than html <iframe> tag.

To use amp-iframe you must follow these rules iframe must be at least 600px or 75% of the first viewport away from the top and can only request resources via HTTPS.

Example for amp-iframe
 <amp-iframe width=\"500\"
      sandbox=\"allow-scripts allow-same-origin allow-popups\"

To include an amp-iframe, first include the following script to the <head>

<script async custom-element=\"amp-iframe\"

Amp also provide some more tags that we can use when require <amp-selector>, <amp-sidebar>,<amp-facebook>,<amp-instagram>,<amp-pinterest>,<amp-playbuzz>,<amp-twitter>,<amp-vine>,<amp-form>,<amp-font>,<amp-dynamic-css-classes>,<amp-anim>,<amp-app-banner> and more you can refer it on amp officia site.

Note: Also check AMP page example code