0

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

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.

| improve this answer | |
  • 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 – Emmanuel Tochukwu Aloysius May 18 at 12:37
  • @EmmanuelTochukwuAloysius There's some plugin that's generating AMP. Scrutinize each plugin carefully. – Maximillian Laumeister May 18 at 18:08
  • Okay but how do I scrutinized these plugin – Emmanuel Tochukwu Aloysius May 18 at 22:28
  • @EmmanuelTochukwuAloysius Google each of them and see whether they are related to AMP at all. – Maximillian Laumeister May 18 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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