The character encoding of the HTML document was not declared

A javascript console error message may show like this: “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.”

What does that mean?
The problem comes from an inappropriate file encoding when you save the file(ex. *.htm file). The encoding format is not good for the browser to decide the encoding in order to interpret the file content.

How to fix it?
Nowadays we usually use UTF-8 in web development. Pick “UTF-8” format may resolve most cases. Therefore, set the file encoding to UTF-8 when you save the file.


Leave a Reply

Your email address will not be published.