Search code examples
validationxhtml-transitional

Why is my html encoding causing an error?


I am working on a website and when I try to validate the page get the following error:

The character encoding specified in the HTTP header (iso-8859-1) is different from the value in the element (utf-8). I will use the value from the HTTP header (iso-8859-1) for this validation.

Here is the code in my header:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>

I don't see where the iso-8859-1 is coming from. Any suggestions?

Thanks.


Solution

  • It's the webserver which specify the encoding in the HTTP header. It set it to iso-8859-1. But in your page, you wrote:

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

    these two values are incompatible. I can only suppose that the webserver is right (it has sent the data anyway), and the validator makes the same assumption.

    If you want to send UTF-8 encoded files, check that the content is really UTF8 encoded, and check the header informations. Ultimately the behavior depends on the webserver configuration and page generation.