The Character Encoding of the HTML Document Was Not Declared

how to fix The character encoding of the HTML document was not declared

From the error you get, please add this to your <head> ... </head>:

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-5"> 

If the charset above did not work, please try this instead:

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

And I hope you defined the before BODY part of your pages as this:

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>

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

<title> Your Title</title>
</HEAD>
<BODY>
....

EDIT 2:

Before including other any other PHP files in your members.php, type this line first:

header('Content-type: text/html; charset=utf-8');

The character encoding of the HTML document was not declared...but it is

I was able to resolve this, even though I'm not sure why it works. I changed all my extensions to .php from .html even though I do not have any PHP code at all on the site. I'm using jQuery...it makes no sense.

UPDATE - This issue was being caused by mod_pagespeed that I was running on Apache. As soon as I turned it off HTML files rendered fine.

It has to be something with one of these directives. I haven't had time to test it though. What a headache.

ModPagespeedEnableFilters prioritize_critical_css
ModPagespeedEnableFilters resize_mobile_images
ModPagespeedEnableFilters inline_preview_images
ModPagespeedEnableFilters inline_google_font_css
ModPagespeedEnableFilters extend_cache

Character encoding not declared in html document

The error is coming because the browsers expect the encoding format in the first 1024 bytes of the file. It may be the case that there is some content being outputted by the included files in the first case.

The browsers now buffer the first 1024 bytes of the file to check for the character encoding. If the encoding description is not encountered in the first 1024 bytes, this warning is displayed.

In your case, you can use a php header for specifying the content type before the other files are included:

header('Content-type: text/html; charset=utf-8');

For more information, read this:
http://gtmetrix.com/specify-a-character-set-early.html

character encoding of the HTML document was not declared codeigniter

FOUND SOLUTION

In the first lines of Session class constructor, it loads the String helper.
Yesterday I've created a helper called string_helper.php and this conflict was what crashing application.

I renamed my string_helper.php file and now everything works fine.

Thanks all!



Related Topics



Leave a reply



Submit