<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Soldato
Joined
23 Oct 2003
Posts
8,899
Location
Hampshire, UK
Hi

When using XHTML 1.1 Ive been told to change the above line for one which features "xml/html" instead of "text/html" - is this good advice?

Thanks

Dave
 
It's not only good advice, it's the right thing to do. It's technically acceptable to send XHTML 1.0 as 'HTML-compatible' XHTML with a mime-type of text/html. XHTML 1.1, however, should always be served as application/xhtml+xml, as it's an appilcation of XML, not SGML/HTML. XHTML 1.0 should be sent as application/xhtml+xml, but text/html is allowed for backwards compatability with existing user-agents. 99% of sites purporting to be 'XHTML valid' are in fact being interpreted as invalid HTML (closing slashes on <img> etc.).

Code:
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />

Be aware that the <meta http-equiv="Content-Type"> tag is not taken notice of if the server's already sending a default mime-type for .htm/.html files, which is very commonplace. Make sure you're sending the right header e.g. with PHP's header() function. Adding the meta-tag alone will likely have no change on the actual mime-type the file's being sent as when served by a webserver.

It's very important to note that there is limited support for the correct XHTML mime-type - notably in all current and future versions of IE (at least up to and including IE7/Win). Therefore you can't support IE when using XHTML 1.1.

Reference:
 
Back
Top Bottom