Description Adds several dynamic CSS class names onto the <body> element.
Required Script <script async custom-element="amp-dynamic-css-classes" src=""></script>
Examples See AMP By Example's amp-dynamic-css-classes example.


The AMP Dynamic CSS Classes extension adds the following CSS classes onto the <body> element:


One or more referrer classes will be set, one for each level of subdomain specificity. For example, will add three classes: amp-referrer-www-google-com, amp-referrer-google-com, and amp-referrer-com.

We currently have a few special cases:

  • When the user came through a Twitter short link, we instead use as the referrer.

  • When the string "Pinterest" is present in the User Agent string and there is no referrer, we use as the referrer.


The amp-viewer class will be set if the current document is being displayed inside a Viewer.