[Fix] – The character encoding of the HTML document was not declared

Published on
by Saurabh K

Are you getting the “The character encoding of the HTML document was not declared” error? 

The Character Encoding Of The Html Document Was Not Declared
The Character Encoding Of The Html Document Was Not Declared

It is quite a common error that usually occurs in Firefox when you do not specify the character encoding of the HTML document.

Firefox Error

You will receive the following error in the console if you have not declared the character encoding. The full error text you will see is,

Get WP Rocket WordPress Cache Plugin.

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.

[Resolved] – The character encoding of the HTML document was not declared

To resolve this issue, there are two ways to declare the character encoding of the HTML document.

# Using meta charset

This meta tag has to be included right after the starting of the <head> tag.

<meta charset="UTF-8">

# Using meta content

Similar to the above, insert the following meta tag right after the starting of the <head> tag.

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
Web dev with a knack for content writing, speed optimization, SEO, and WordPress magic. I write actionable content and share proven methods. By day: building fast, beautiful sites. By night: chasing coffee and ideas for my next technical write-up. Drop me a line on Twitter, subscribe to my newsletter or buy me a coffee.

Trending Right Now!

Disclaimer: Some of the links on this blog are affiliate links. If you click through and purchase any product, we may earn a commission at no additional cost to you.

Leave a Comment