Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The character encoding declaration of the HTML document was not found

randomly getting this issue come up in my web console of firefox (is the js tab)

Its only just appeared and cant link it to any changes i have made.

The full error is:

The page was reloaded, because the character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

Or this one:

The character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. When viewed in a differently-configured browser, this page will reload automatically. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

The issue points to this line:

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />

To me, that meta tag is okay? Any help as i think it is conflicting and causing issues with other things.

Craig

like image 414
Lovelock Avatar asked Jul 21 '14 21:07

Lovelock


People also ask

How do I fix the character encoding of the HTML document was not declared?

Adding <meta charset="utf-8"/> in the html code solved my issue in Firefox. Save this answer.

How do you declare character encoding in HTML?

Always declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes (called a pragma directive).

How do I set HTML to UTF-8?

The character encoding should be specified for every HTML page, either by using the charset parameter on the Content-Type HTTP response header (e.g.: Content-Type: text/html; charset=utf-8 ) and/or using the charset meta tag in the file.

Which is the default character encoding HTML5 ISO 8859 1 UTF-8 UTF 32 UTF 16?

The default character encoding in HTML5 is UTF - 8.


1 Answers

Charset is a parameter of the content-type, not a separate attribute:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

Or, if you want to use the HTML 5 style:

<meta charset="utf-8">

You should also note the error message:

not found when prescanning the first 1024 bytes of the file

You might need to move the meta tag up the document. Ideally, it should be the first tag inside the <head>.

like image 77
Quentin Avatar answered Sep 26 '22 14:09

Quentin