7

I am trying to link to css file :

<link href="/semanticui/semantic.css" rel="stylesheet" />

Opening chrome in #development=1 mode to test my page for amp. I am getting this error :

The attribute 'href' in tag 'link rel=stylesheet for fonts' is set to the invalid value '/semanticui/semantic.css'.
osmanraifgunes
  • 1,438
  • 2
  • 17
  • 43

4 Answers4

14

External stylesheets are not permitted. Use inline styling to avoid the additional request for css.

More info can be found at: https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#stylesheets

Authors may add custom styles to a document using a single <style amp-custom> tag in the head of the document.

Jeff Deskins
  • 1,650
  • 1
  • 10
  • 9
8

i am using php pages so I do the following to add my custom css page, so i can seperate it and also include in all pages so changing only once etc.

<style amp-custom>
  <?php readfile( getcwd() . "/css/main.min.css"); ?>
</style>
Simon Davies
  • 3,668
  • 9
  • 41
  • 69
1

Any styling to the page and its elements is done using common CSS properties. Style elements using class or element selectors in an inline stylesheet in the , called <style amp-custom>

here is sample code:

<style amp-custom>
  /* any custom style goes here */
  body {
    background-color: white;
  }
  amp-img {
    background-color: gray;
    border: 1px solid black;
  }
</style>
Fazlul Karim
  • 367
  • 1
  • 2
  • 13
0

You can use this:

<style amp-custom>
    <?php echo file_get_contents(STYLESHEETPATH.'/style.css'); ?>
</style>
Matt
  • 1,518
  • 4
  • 16
  • 30