Re: [WSG] content type etc
Lachlan Hunt wrote: That makes no sense whatsoever! You never need to use the meta element for content served over HTTP for *any* browser. IE supports the HTTP headers just fine: I agree with Lachlan, to 90 %. If I recall things correctly, this is how things *should* work. 1. If the server sends a MIME-declaration, that should be used by user agents. This happens almost always. 2. If not (1): If the content is XML-ish, as in XHTML, and has an XML prologue where the encoding is specified, UAs use that. 3. If not (2): If the content is (X)HTML, UAs use the meta-tagg. When loading pages from local files or from an FTP-server, where obviusly no HTTP-headers are sent, this is what the browser should use to get the encoding. Value of declaratons: HTTP-headers XML-prologue Meta-tags But then there is MSIE, a browser that thinks that it actually knows better than the server or HTML-coder, and inspects the actual content and overrides all settings if it feels like it. This behaviour makes it very forgiving when things are set up in the wrong way, but that is *not* a good thing as it may lead to bigger problems further down the road. I have had problems with this behavior when I for a while was forced to use a server that sent CSS-files as text/html, but MSIE forgave that and the admin (himself only using IE) refused to admit that it was wrongly configured. In Firefox the CSS was not used even if the link tag said link type=text/css I've seen other sites where swedish letter fail to show up properly, etc. MSIE-values: It's own judgement HTTP-headers XML-prologue Meta-tags Bottom line: Meta-tags do *not* override http-headers, but MSIE sometimes override them, having inspected the actual content of a file. Lars Gunther ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Keryx webb wrote: 3. If not (2): If the content is (X)HTML, UAs use the meta-tagg. When loading pages from local files or from an FTP-server, where obviusly no HTTP-headers are sent, this is what the browser should use to get the encoding. Meta elements are *not* used in XHTML files at all, this only applies to HTML. But this needs to be clarified that XHTML served as text/html *is* HTML, regardless of what the DOCTYPE says. Value of declaratons: HTTP-headers XML-prologue Meta-tags It's not quite as simple as that. It's more like this: for text/html: HTTP headers -- meta element -- content-sniffing for application/xml and */*+xml (excluding text/*) HTTP headers -- XML Declaration -- BOM (UTF-8 or UTF-16 LE/BE) for text/xml HTTP headers -- US-ASCII (XML declaration is ignored) MSIE-values: It's own judgement HTTP-headers XML-prologue Meta-tags Again, it's not quite as simple as that. For text/html, the XML declaration is *not* used at all, IE doesn't even understand it and triggers quirks mode if it's present. IE supports application/xml and text/xml and it will respect the XML declaration, but I'm not sure how standards compliant it's behaviour is with regard to encoding detection in XML. I'm not aware of any case where IE will override the character encoding in the HTTP headers, only the MIME type. Can you provide a demonstration or provide a link to some documentation of the bug? -- Lachlan Hunt http://lachy.id.au/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Thanks a lot for the answer, Lachlan. The reason I asked you this is that I normally send two different content-type according to the browser. That is. If you access my personal site using IE you will notice that I use a meta tag to declare the mime-type, and in the case of IE it would be text/html, whereas if you access using any other browser the page will be served as XML, using a xml declaration, without any meta-tag to declare the mime-type. Now, even though the all thing validates as XHTML1.0 Strict, I was wondering whether that would be the correct practice. This the link to my personal page: www.noblocodenotas.com Best regards. Paolo Dodet
Re: [WSG] content type etc
Sorry, I did a mistake! :) ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Thanks a lot for the answer, Lachlan. The reason I asked you this is that I normally send two different content-type according to the browser. That is. If you access my personal site using IE you will notice that I use a meta tag to declare the mime-type, and in the case of IE it would be text/html, whereas if you access using any other browser the page will be served as XML, using a xml declaration, without any meta-tag to declare the mime-type. Now, even though the all thing validates as XHTML1.0 Strict, I was wondering whether that would be the correct practice. This the link to my personal page: www.noblocodenotas.com Best regards. Paolo Dodet Huston, we've got a problem! :D ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Hello! Paolo Dodet skrev: That is. If you access my personal site using IE you will notice that I use a meta tag to declare the mime-type, and in the case of IE it would be text/html, whereas if you access using any other browser the page will be served as XML, using a xml declaration, without any meta-tag to declare the mime-type. When using the meta tag to declare content-type, it is best practice to put it as early in the html as possible. I always put it immediately after the head opening tag. The logic behind this is that the browser should have to parse as little as possible before finding the content-type meta tag (as it sometimes has change the encoding of everything before the meta tag). This also shows why this information always should be sent with the http headers in the first place. /AndersN ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Paolo Dodet wrote: That is. If you access my personal site using IE you will notice that I use a meta tag to declare the mime-type, and in the case of IE it would be text/html, whereas if you access using any other browser the page will be served as XML, using a xml declaration, without any meta-tag to declare the mime-type. http://www.noblocodenotas.com/ That makes no sense whatsoever! You never need to use the meta element for content served over HTTP for *any* browser. IE supports the HTTP headers just fine: Besides, your server is not sending the correct HTTP response headers to any browser, even though it is stripping the meta element and adding the xml declaration for those that support it. These are the response headers sent to Firefox regardless of the value of the Accept header. HTTP/1.x 200 OK Date: Tue, 17 Jan 2006 21:49:22 GMT Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.10 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7e X-Powered-By: PHP/4.3.10 Keep-Alive: timeout=1, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html Regardless of whether the Accept header contained application/xhtml+xml or only text/html, the meta element was stripped and the XML declaration was added, yet the Content-Type of text/html remained the same. These response headers were sent when the browser identified itself as IE (including Firefox when I modified the User-Agent header to match IE6): HTTP/1.1 200 OK Date: Tue, 17 Jan 2006 21:44:21 GMT Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.10 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7e X-Powered-By: PHP/4.3.10 Transfer-Encoding: chunked Content-Type: text/html Regardless of the Accept header again, the meta was element was included, the XML declation was not. This proves that not only are you failing to set the HTTP headers correctly, but you're changing the document based on the perceived browser support judged only by the the User-Agent request header. In other words, you're browser sniffing and that is never the right way to do things. If you wish to do content negotiation, please do so properly. This article [1] posted here earlier explains the correct way to set the headers and detect based on the Accept header. For HTML, the Content-Type response header should contain this: Content-Type: text/html; charset=ISO-8859-1 Don't include the XML declaration. (Note: I recommend you switch to using UTF-8 instead, but it requires that your files actually be saved as UTF-8, not just changing the value in this header) For XHTML, use this: Content-Type: application/xhtml+xml Include the XML declaration to declare the encoding. *DO NOT* use the meta element for any browser at all, in fact don't even include it in your document under any circumstances when serving over HTTP. (It can be useful for testing on the local file system, but useless for anything beyond that). [1] http://www.thatstandardsguy.co.uk/2006/01/16/content-negotiation/ -- Lachlan Hunt http://lachy.id.au/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Thanks very much Lachlan, I'll start to study the all matter as soon as I'll get home. A couple of hours I guess. I really need to work this out once and for all. Best Regards. Paolo Dodet -- Real knowledge is based on experience. All that is left is pure vanity.
Re: [WSG] content type etc
On 15/01/06, designer [EMAIL PROTECTED] wrote: Hi All,More questions as I battle to understand stuff about headers and xhtml . . .snip--Best Regards,Bob McClellandCornwall (UK) www.gwelanmor-internet.co.ukEven on a Sunday, you'll probably get a quick answer but tomorrow I will be publishing an article on that subject.Proper announcement tomorrow morning :-) -- Karl DawsonCrusader for Web Standards and Accessibilityhttp://www.thatstandardsguy.co.uk-- Accessites Team Member - http://www.accessites.org/--The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee - W3C Director and inventor of the World Wide Web
RE: [WSG] content type etc
!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; lang=en xml:lang=en head meta http-equiv=content-type content=text/html; charset=utf-8 / Is the correct layout that should be used to validate your template (index.php) file -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of designer Sent: Monday, 16 January 2006 1:34 AM To: webstandards group Subject: [WSG] content type etc Hi All, More questions as I battle to understand stuff about headers and xhtml . . . My question is about the two alternative meta headers: meta http-equiv=Content-Type content=text/html; charset=utf-8 / or meta http-equiv=Content-Type content=application/xhtml+xml; charset=utf-8 / Someone (pretty sure it was Lachlan) said that the content=text/html; (or indeed content=application/xhtml+xml;) bit was a waste of time and didn't do anything. So am I best changing it to simply: meta http-equiv=Content-Type content=charset=utf-8 / I would then end up with : ?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' xml:lang='en' head titleTester/title meta http-equiv=Content-Type content=charset=utf-8 / head etc. Is that 'sensible'? Is it 'correct'? Sorry if this is dumb. -- Best Regards, Bob McClelland Cornwall (UK) www.gwelanmor-internet.co.uk ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help ** ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Gee Rimantas, Such enlightenment! :-) Best Regards, Bob McClelland Cornwall (UK) www.gwelanmor-internet.co.uk Rimantas Liubertas wrote: ... I would then end up with : ?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' xml:lang='en' head titleTester/title meta http-equiv=Content-Type content=charset=utf-8 / head ... Is that 'sensible'? No. Is it 'correct'? No. Regards, Rimantas -- http://rimantas.com/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help ** -- ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Gee Rimantas, Such enlightenment! Oh, well, OK. According to [1] XHTML1.1 should not be sent with MIME type of text/html. Some may argue that should not is not the same as must not and need to serve IE justifies the use of text/html MIME type for XHTML1.1, but I belong to XHTML as text/html is meaningless camp. In case of application/xhtml+xml MIME type meta element makes no sense at all, because it is not used for anything - neither for mime type (which is never used for, be it html or xhtml), nor for character encoding information [2]. HTTP headers and XML declaration are used for this purpose. As for omitting mime type from meta element and leaving only charset info... This might work only in text/html context, in which such omission makes no sense. On the other hand charset info is optional in Content-type HTTP header, not the content type part itself ;) And you were right that was Lachlan who wrote about Content-type headers and meta element, see [3]. [1] http://www.w3.org/TR/xhtml-media-types/ [2] http://www.mozilla.org/docs/web-developer/faq.html#xhtmldiff [2] http://lachy.id.au/log/2006/01/content-type Regards, Rimantas -- http://rimantas.com/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Ah... nearly. meta element content-type declarations ARE used, just not when the page viewed is coming from a non-local filesystem/HTTP. So it's necessary in the sense that it enables people to save your page and for that page to be 'usable' in a more general sense (though browsers have a tendency to inject crap into saved pages: there's only so much you can do!) On 1/16/06, Rimantas Liubertas [EMAIL PROTECTED] wrote: Gee Rimantas, Such enlightenment! Oh, well, OK. According to [1] XHTML1.1 should not be sent with MIME type of text/html. Some may argue that should not is not the same as must not and need to serve IE justifies the use of text/html MIME type for XHTML1.1, but I belong to XHTML as text/html is meaningless camp. In case of application/xhtml+xml MIME type meta element makes no sense at all, because it is not used for anything - neither for mime type (which is never used for, be it html or xhtml), nor for character encoding information [2]. HTTP headers and XML declaration are used for this purpose. As for omitting mime type from meta element and leaving only charset info... This might work only in text/html context, in which such omission makes no sense. On the other hand charset info is optional in Content-type HTTP header, not the content type part itself ;) And you were right that was Lachlan who wrote about Content-type headers and meta element, see [3]. [1] http://www.w3.org/TR/xhtml-media-types/ [2] http://www.mozilla.org/docs/web-developer/faq.html#xhtmldiff [2] http://lachy.id.au/log/2006/01/content-type Regards, Rimantas -- http://rimantas.com/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help ** -- Joshua Street http://www.joahua.com/ +61 (0) 425 808 469 ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Ah... nearly. meta element content-type declarations ARE used, just not when the page viewed is coming from a non-local filesystem/HTTP. So it's necessary in the sense that it enables people to save your page and for that page to be 'usable' in a more general sense (though browsers have a tendency to inject crap into saved pages: there's only so much you can do!) When file is saved and then loaded Mozilla determines which parser - html, o xml to use by file extension. So if you save xhtml file as .html/.htm and then load it, it will be parsed by html parser, and in this case META is taken into account. If file is saved as .xhtml, .xml or .xht it will be parsed with xml pareser and META is ignored. Regards, Rimantas -- http://rimantas.com/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
On 15/01/06, Rimantas Liubertas [EMAIL PROTECTED] wrote: When file is saved and then loaded Mozilla determines which parser - html, o xmlto use by file extension. So if you save xhtml file as .html/.htm andthen load it, it willbe parsed by html parser, and in this case META is taken into account. If file is saved as .xhtml, .xml or .xht it will be parsed with xmlpareser and META is ignored. So, what about files saved with a .php extension? Could you shed some light on it, please? For I feel very confused about the all matter, and I can't find clear enough material online. Paolo Dodet
Re: [WSG] content type etc
Rimantas Liubertas wrote: As for omitting mime type from meta element and leaving only charset info... This might work only in text/html context, in which such omission makes no sense. Although I suspect it will work just fine in most, if not all modern browsers, that doesn't make it right. In fact, I read somewhere a long time ago that some browsers (NN4, I think) will accept something like. meta charset=UTF-8 Of course, that is completely wrong and should not be used at all. When used in combination with the http-equiv attribute, the value of the content attribute must match the syntax of the equivalent value in HTTP headers. It is, however, better to use real HTTP headers instead of the inferior meta element substitute. -- Lachlan Hunt http://lachy.id.au/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **
Re: [WSG] content type etc
Paolo Dodet wrote: On 15/01/06, Rimantas Liubertas [EMAIL PROTECTED] wrote: When file is saved and then loaded Mozilla determines which parser - html, o xml to use by file extension. So if you save xhtml file as .html/.htm and then load it, it will be parsed by html parser, and in this case META is taken into account. If file is saved as .xhtml, .xml or .xht it will be parsed with xml pareser and META is ignored. So, what about files saved with a .php extension? Rimantas was talking about when the files are loaded from the local file system, where there are no HTTP headers available. In the context of the web, the file extension is essentially meaningless, it's the MIME type sent in the HTTP Content-Type header that matters. The file extension only exists as a means to determine the file type on your local file system and use by the web server to determine various HTTP headers. When served over HTTP, the file extension is (well, it should be [1]) completely meaningless to the browser. Most of the common extensions are associated with standard MIME types, so that, for example, when you upload a .html file to your server, the server (theoretically) knows what Content-Type to send (assuming it's been configured properly). These are some of the most common file extensions and their most commonly associated MIME types: Extensions | MIME |-- .html .htm | text/html .xhtml .xht | application/xhtml+xml .xml| application/xml (preferred) or text/xml (not recommended) .txt| text/plain .css| text/css .js | application/javascript, text/javascript, etc. .jpeg .jpg | image/jpeg .gif| image/gif .png| image/png PHP isn't directly associated with a specific MIME type, since it's dynamic content that can be anything at all. It is usually (and defaults to sending) text/html, but can be set to anything using the header() function. [1] The evil practice known as Content Sniffing makes use of the file extension (among other things) to determine the file type in the event that or no content-type information is sent by the server, or if it is believed by the browser that the server is wrong. This is why, for example, HTML documents served as text/plain will be incorrectly rendered as HTML by IE. -- Lachlan Hunt http://lachy.id.au/ ** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list getting help **