• Resolved michael.aulia

    (@michaelaulia)


    Hi,
    I got lots of validation errors from Google on my AMP pages with error of “The text inside tag ‘style amp-custom’ contains ‘CSS !important’, which is disallowed.”.

    I notice the plugin outputs many of these lines, for example: .amp-wp-content .amazon-image-wrapper a amp-img img{height:auto;position:relative!important}

    If I deactive the plugin, these CSS types that Google AMP validator does not like go away. Wondering if you can provide an update to work around these issues (or if something we can do to remove these generations in the mean time), and if it’s going to have any effect without the “important” bit?

    Thanks,
    Mike

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Mike,
    You can remove the styles using this WordPress hook:
    remove_action( 'amp_post_template_css', 'amp_appip_ampstyles' , 1000);

    You can add that to your functions.php file (preferably the child theme functions.php file if using a child theme) after the opening <?php tag (and after any comments). That will remove the offending styles you are mentioning.

    Sorry, I was not aware that the AMP CSS did not allow !important – I guess I need to brush up on AMP specifications some more in the very near future!

    Thanks for bringing this to my attention. If you have an issue adding it, let me know – I can throw it in a quick temporary plugin for you until the issue is resolved in the main plugin.

    Warm regards,
    Don

    Thread Starter michael.aulia

    (@michaelaulia)

    Hi Don,
    That works like a treat, thanks for the quick and easy solution!

    It’s cool, we all learn new things each day and you can’t possibly know and cover everything out there ?? Cheers

    Thanks for the update Mike!
    I’ll also add a setting to turn this on/off for future as well.

    Warm regards,
    Don

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘AMP Validation Error for CSS: !important’ is closed to new replies.