[TxMt] Re: Misguided use of content-type in XHTML/1.1 template

Jacob Rus jrus at hcs.harvard.edu
Tue Mar 6 00:20:42 UTC 2007


Allan Odgaard wrote:
> On 5. Mar 2007, at 17:13, hadley wickham wrote:
>> Isn't the content only important when you're sending things "over the 
>> wire" so the program at the other end can recognise what to do?  The 
>> meta tag is just a hack for html to give the page author some way of 
>> overriding the content-type that the server is sending.
> 
> I don’t fully follow this. But the meta tag is not a hack, it is a way 
> to specify the content type (and encoding, etc.) when the page is NOT 
> sent over http, i.e. when it is loaded from a non-http server (like your 
> disk drive). The meta tag never overrides the info sent by the server, 
> on the contrary, it is the server which overrides the meta tag.

Okay, here's what Ian Hickson said in response to my email:

> On Mon, 5 Mar 2007, Jacob Rus wrote:
>> Even though xhtml has real problems for use on the web, and should
>> probably be avoided by most users, some users need it for specific
>> applications, and so it would be good to include a correct and useful
>> default template for xhtml 1.1.  So, is it wrong to include the `<meta>`
>> tag, or is there some better way to indicate content type within an xml
>> document?
> 
> If the file is XML, it shouldn't have a <meta> with Content-Type data. It
> will never be used by the browser (it's only used when the browser already
> knows it's HTML).
> 
> In fact, the "text/html" part of the Content-Type <meta> line is never
> examined. That line is only ever examined for working out the encoding of
> HTML documents. For XML documents that are actually treated as XML, the
> <?xml?> declaration is the one that matters.
> 
> HTH,

And on a bit more prodding:

>> So should a generic XHTML 1.1 template have a <?xml?> declaration then?
> 
> If you want to declare the encoding, yes.

So I think we should make the default template instead look like:

     <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
       "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

     <html xmlns="http://www.w3.org/1999/xhtml"
       version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en">
     <head>
         <title>${TM_NEW_FILE_BASENAME}</title>

     </head>

     <body>


     </body>
     </html>

-Jacob




More information about the textmate mailing list