The difference between an AMP webpage and a Web Story built with AMP is the amp-story component. It is the only direct child of the document and must contain the standalone attribute. All Web Story pages, layers, and elements are defined within the tags.
<html⚡><head><metacharset="utf-8"><title>Joy of Petstitle><linkrel="canonical"href="pets.html"><metaname="viewport"content="width=device-width"><styleamp-boilerplate>body{-webkit-animation:-amp-start8ssteps(1,end)0s1normalboth;-moz-animation:-amp-start8ssteps(1,end)0s1normalboth;-ms-animation:-amp-start8ssteps(1,end)0s1normalboth;animation:-amp-start8ssteps(1,end)0s1normalboth}@-webkit-keyframes-amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes-amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes-amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes-amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes-amp-start{from{visibility:hidden}to{visibility:visible}}style><noscript><styleamp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}style>noscript><scriptasyncsrc="https://cdn.ampproject.org/v0.js">script><scriptasynccustom-element="amp-video"src="https://cdn.ampproject.org/v0/amp-video-0.1.js">script><scriptasynccustom-element="amp-story"src="https://cdn.ampproject.org/v0/amp-story-1.0.js">script><styleamp-custom>...style>head><body><amp-storystandalonetitle="Joy of Pets"publisher="AMP tutorials"publisher-logo-src="assets/AMP-Brand-White-Icon.svg"poster-portrait-src="assets/cover.jpg"><amp-story-pageid="cover"><amp-story-grid-layertemplate="fill"><amp-imgsrc="assets/cover.jpg"width="720"height="1280"layout="responsive"alt="...">amp-img>amp-story-grid-layer><amp-story-grid-layertemplate="vertical"><h1>The Joy of Petsh1><p>By AMP Tutorialsp>amp-story-grid-layer>amp-story-page><amp-story-pageid="page1"><amp-story-grid-layertemplate="vertical"><h1>Catsh1><amp-imgsrc="assets/cat.jpg"width="720"height="1280"layout="responsive"alt="...">amp-img><q>Dogs come when they're called. Cats take a message and get back to you. --Mary Blyq>amp-story-grid-layer>amp-story-page>
...
amp-story>body>html>
Users may be viewing Web Stories in areas with low network connection or older devices. Ensure they enjoy their experience by following these best practices.
Background color
Specify a background color for each Web Story page. Having a background color provides a good fallback if the user’s conditions prevent them from downloading images or video assets. Choose a color that is representative of the dominant color of the page’s intended background asset, or use a consistent color theme for all story pages. For readability, ensure the background color has sufficient color contrast with the foreground text. Ideally, aim for a color contrast ratio of 4.5:1. If this is not possible, consider adding an additional background behind the text itself instead that does result in a sufficient contrast.
Define the background color for pages within the tags in the head of the Web Story document or inline on the component.
Layering elements
The system header contains controls such as the mute and share icons. It appears at a higher z-index than the background image and video. Ensure that no essential information is covered by these icons.
Aspect ratio
Design Web Story assets at a 9:16 aspect ratio. Because page height and width varies across browsers and devices don’t place essential content close to page edges.
Poster images
A poster image is displayed to user’s while a video is downloaded. The poster image should be representative of the video to allow for a smooth transition. Specify a poster image by adding the poster attribute to your amp-video element and pointing it to the image location.
fallback>This browser does not support the video element.
Resolution and quality
Encode videos to adjust quality for the following recommended optimizations:
MP4
-crf 23
WEBM
-b:v 1M
Try to keep HLS segments under 10 seconds in duration.
Format and size
Keep videos smaller than 4MB for optimal performance. Consider splitting large videos up over multiple pages.
If you can only provide a single video format, provide MP4. Use the following video codec:
MP4, HLS and DASH
H.264
WEBM
VP9
Specify vs src
Use child elements within the component to specify the video source over the src attribute. Using the element allows you to specify the video type and add backup video sources. You must use the type attribute to specify the MIME type. Use application/x-mpegurl or application/vnd.apple.mpegurl for HLS videos. For all other video types, use the video/ MIME prefix and follow with the video format, such as ”video/mp4”.
The auto-advance-after attribute exposed by amp-story-page specifies if and when a story page should advance without the user tapping. To advance after a video, point the attribute to the video id.
<amp-story-pageauto-advance-after="myvideo">
Landscape orientation and full bleed desktop experience
The Web Story format supports an optional landscape orientation and full bleed desktop experience. This changes the desktop experience to an immersive full bleed mode, replacing the default three portrait panels experience. On mobile, it allows users to view stories when their device is held horizontally in landscape mode.
While this is currently opt-in and optional, we strongly recommend making sure that users on mobile devices are able to view stories in whatever orientation best suits their needs - otherwise, they will simply be presented with a "The page is best viewed in portrait mode" message.
Opt-in to landscape orientation and full bleed desktop support by adding the supports-landscape attribute to the component.
<amp-storystandalonesupports-landscapetitle="Joy of Pets"publisher="AMP tutorials"publisher-logo-src="assets/icon.svg"poster-portrait-src="assets/cover.jpg">amp-story>
We use cookies to understand how you use our site and to improve your experience. By continuing to use our site, you accept our use of cookies and privacy policy.