Reputation: 93
How can I add external css styles in amp page. This tag I am using to include css file.
<link href="css/cssnew.css" rel="stylesheet" media="screen">
Its giving the following error: The attribute 'href' in tag 'link rel=stylesheet for fonts' is set to the invalid value 'css/cssnew.css'. (see https://www.ampproject.org/docs/reference/spec#custom-fonts)
In amp documentation it specifies to use inline styling.
<style amp-custom>
//css code
</style>
But how to include all the required css inside this tag since it has certain limits. Can anybody explain me regarding this with an example as I am completely new to amp pages. Thank you in advance
Upvotes: 3
Views: 1565
Reputation: 145
By using PHP you can do that but css should not exceed 50kb. You have to include this line in the head section
<?php readfile( getcwd() . "/amp.css"); ?>
CSS:
<style amp-custom>
body {
background-color: blue;
}
</style>
Upvotes: 3
Reputation: 1409
It is not possible to add external style sheets, like css. It needs addional network request, so it slows down loading the site.
See the Basic howto.
Upvotes: 3