Support » Plugin: AMP » Css Not valid

  • Resolved miriazab



    A few days ago I see on the Search Console that there is a syntax error in the AMP style sheets. I haven’t touched any plugin file and I can’t find in which file is the error. Can you please tell me how to fix it?


    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ryan Kienstra


    Hi @miriazab,
    Thanks for letting me know about those issues. I also saw them:

    1. Custom JavaScript is not allowed.
    2. CSS syntax error in tag ‘style amp-custom’ – unterminated comment.
    Validation errors

    1. Do you have any other plugin related to AMP, SSL or HTTPS? Some plugin is outputting this <script>, which isn’t allowed in AMP:

    <script>if (document.location.protocol != "https:") {document.location = document.URL.replace(/^http:/i, "https:");}</script>

    Even in non-AMP, it’s usually not a best practice to have inline <script> tags in the <head>.

    2. The CSS looks to be coming from this line in the Yuzo Related Post plugin:

    Disabling that plugin would probably take care of that issue, though you’re probably using that plugin for a reason 🙂

    But that HTML is still valid (if unusual), and this AMP plugin isn’t handling commented-out inline styles properly.

    This looks to be fixed in the upcoming 1.0 release of this plugin. There’ll probably be at least a Beta version in June.

    For this markup:

    <div class="yuzo-img-wrap " style="/*width: 126.5px;height:88px;*/">

    The style rule in AMP doesn’t have a closing comment: */

    • This reply was modified 8 months, 4 weeks ago by  Ryan Kienstra.
    Plugin Contributor Ryan Kienstra


    JavaScript Issue

    Hi @miriazab,
    Could you please try this code in your theme’s functions.php or in a plugin? It looks like the Really Simple SSL plugin is outputting that script. Thanks to @zelldi for pointing that out on another topic.

    This blocks the script on AMP endpoints only:

     * Prevents outputting an illegal <script> if this is an AMP endpoint.
     * @param string $script The <script>
     * @return string $script The unchanged <script>, or an empty string if this is on an AMP endpoint.
    add_filter( 'rsssl_javascript_redirect', function( $script ) {
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    		return '';
    	return $script;
    } );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Css Not valid’ is closed to new replies.