1

How can I resolve the @charset “invalid tag error” on my AMP page?

Here is the line of code on the page that is causing the issue:

<style amp-custom>
    @charset "UTF-8";
    (...more CSS...)
</style>
0

1 Answer 1

1

According to MDN, @charset:

cannot be used ... inside the <style> element where the character set of the HTML page is relevant.

https://developer.mozilla.org/en-US/docs/Web/CSS/@charset

Since AMP pages are required to be UTF-8 encoded and they use meta tags to specify such, this falls under the case where the "character set of the HTML page is relevant".

In short, AMP pages are not allowed to use @charset in a style tag.

Remove the @charset declaration from inside if your style tag, and the error will go away.

You can use the AMP Validator to help debug.

4
  • I don't know how to remove the @charset, where should I navigate to. I have checked all through my WordPress dashboard, the plugins directory and can't find the AMP HTML. Please someone should help May 18, 2020 at 12:37
  • @EmmanuelTochukwuAloysius There's some plugin that's generating AMP. Scrutinize each plugin carefully. May 18, 2020 at 18:08
  • Okay but how do I scrutinized these plugin May 18, 2020 at 22:28
  • @EmmanuelTochukwuAloysius Google each of them and see whether they are related to AMP at all. May 18, 2020 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.