Results 1 to 3 of 3
Jul 29, 2014, 01:33 #1
- Join Date
- Jul 2014
- 0 Post(s)
- 0 Thread(s)
Trying to Understand Content-Type
I am reading the FAQ section in this forum and I have seen this:
Can I set the MIME type with a <meta/> tag?
No. A user agent needs to know the content type before it starts parsing the response body. When it encounters an element like this, it's already too late:
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
The MIME type must be sent as a Content-Type HTTP header. The character encoding should be specified in the XML declaration (see above).
Nevertheless, if I open the code of this same forum, I find this meta:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
Can anyone explain it to me please?
Thanks very much.
Jul 29, 2014, 08:25 #2
Aug 1, 2014, 08:18 #3
- Join Date
- Aug 2007
- 51 Post(s)
- 2 Thread(s)
The meta tags are often read *IF* the server did not send an appropriate header.
The meta tag setting the charset is also ignored if the server sent a different one.
If neither server headers nor meta tags for something are present, the user agent (browser) gets to guess, or use some internally-selected default. IE6 used to use heuristics to guess the charset of a page, after which it would then start re-rendering the page all over again.
It's considered good practice to have a charset meta tag as a backup anyway, even though stuff like the UTF-7 hack are very very unlikely : )