W3C home > Mailing lists > Public > www-validator@w3.org > December 2005

Re: Content type is wrong

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Fri, 23 Dec 2005 10:57:49 +1100
Message-ID: <43AB3D7D.4010805@lachy.id.au>
To: magick <jasper.magick@gmail.com>
CC: www-validator <www-validator@w3.org>

magick wrote:
> I am using the XHTML 1.1 doctype and this is is what I have as my 
> content type
> 
> <meta http-equiv="content-type" content="application/xhtml+xml; 
> charset=iso-8859-1" />

For real XHTML, that meta element is completely useless.  For HTML 
(including XHTML served wrongly as text/html), it's an inferior 
substitute for read HTTP headers and it will only ever set the character 
encoding when you've failed to do so properly.

The MIME type needs to be known *before* parsing can begin, and that 
meta element will not be seen until afterwards.  Also, the real HTTP 
headers always take precedence.

You can use this tool to see the HTTP headers sent by your server:
http://cgi.w3.org/cgi-bin/headers

If you're using Apache, it's a trivial exercise to configure your server 
to send the proper Content-Type header including both the MIME type and 
the character encoding information.  Look up .htaccess files and the 
AddType, AddCharset and AddDefaultCharset directives in the Apache 
documentation.  (Google will find them for you).

If you're using PHP, ASP, JSP or some other server side scripting 
language, you can use something like PHP's header() function, JSP's 
@page directive or whatever ASP uses.  (Look up the documentation for 
whatever you're using).

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Friday, 23 December 2005 00:16:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:20 GMT