The reason all these companies are getting on board is simple: load speed. Rather, we’re going to get down to the brass tacks of exactly what AMP means for you when you’re actually coding up websites. Well, to be direct, because it’s Google. The <amp-ad>... Quick Tip: Make AMP’s Inline CSS Easier With Jade or PHP. Validator.ampproject. Learn AMP by Example. Supported CSS. Like all web pages, AMP pages are styled with CSS, but you can’t reference external stylesheets (with the exception of custom fonts) and inline style attributes aren’t allowed. Also, certain style properties related to animations have been disallowed due to performance implications, and the embedded style tag must be in the <head> of the page. These different kinds of limitations are there to improve the performance of your pages, but can be overwhelming at first. When in doubt, always test your styles using the AMP validator. Even though inline stylesheets add bytes to every page, the saved round trip request to another external file would be even slower.
Having your styles in the <head> of the page effectively means that all your CSS becomes critical CSS that is loaded before the rest of the page is loaded, so only include what you need. Read on to learn how to style your AMP pages: Learn more about critical CSS in this article, Understanding Critical CSS. Add styles to a page. Style & layout. Styling and layout on AMP HTML pages is very similar to normal HTML pages – in both cases, you'll use CSS. However, AMP limits some use of CSS for performance and usability reasons, while expanding responsive design capabilities with features like placeholders & fallbacks, advanced art direction via srcset and the layout attribute for better control over how your elements display.
Add styles to a page Add all CSS inside a <style amp-custom> tag in the head of the document. For example: Define component styles with class or element selectors using common CSS properties. <body><p>Hello, Kitty. Layout elements responsively Specify the size and position for all visible AMP elements by providing a width and height attribute. Set the layout to responsive. Provide placeholders & fallbacks The built-in support for placeholders and fallbacks means your users never have to stare at a blank screen again.
Art direct your images Validate your styles and layout. Quick Tip: Make AMP’s Inline CSS Easier With Jade or PHP. Google AMP Cache | Google Developers. AMP on Google | Google Developers. Accelerated Mobile Pages Project. Up and Running With AMP - CSS and AMP. Accelerated Mobile Pages Project – AMP.