[Fix] – The character encoding of the HTML document was not declared
Are you getting the “The character encoding of the HTML document was not declared” error?
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,
“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">