Jump to content

Mime type and document type


Glom

Recommended Posts

I went to validate my home page. It said the page was valid XHTML 1.1 but gave one warning.

Conflict between Mime Type and Document TypeThe document is being served with the text/html Mime Type which is not a registered media type for the XHTML 1.1 Document Type. The recommended media type for this document is: application/xhtml+xmlUsing a wrong media type for a certain document type may confuse the validator and other user agents with respect to the nature of the document, and you may get some erroneous validation errors. How to fix this problem? One of the following techniques should help:If you are serving a static file on a Web server, changing its extension should help. Use e.g .xhtml for XHTML or .mathml for MathML. You may need to reconfigure your Web server. This Setting up MIME Types tutorial has instructions for Apache, Tomcat and IIS. If the document is generated dynamically, the scripting language should allow you to set up the mime type: this article on MIME Types and Content Negotiation has examples in PHP, Perl, and ASP.
Now what is that all about?
Link to comment
Share on other sites

Guest FirefoxRocks

Unless you are serving XHTML as XML, you shouldn't be using XHTML 1.1. XHTML 1.1 is to be served as application/xhtml+xml, which can be either configured by server-side scripting (PHP, ASP, etc) or by saving the filename with a .xhtml extention instead of .html.Beware: Internet Explorer cannot read application/xhtml+xml files, and will prompt you to download it. Also, one tiny mistake in your page and the Yellow Screen of Death comes up in Firefox, Flock, Netscape, etc.I recommend using XHTML 1.0 if you are going to serving the pages as text/html.

Link to comment
Share on other sites

Let me guess, you don't undestand what "served as" means, right? Thus, you don't get the rest....A web server always transmits plain text on the network. It's up to the browser to "decipher" what does that text do. It could form an image, an HTML page, a JavaScript, etc. etc. etc.To assist the browser in this, the web server sends a special text at the top of the document. Or should I say a few special lines of text, called "HTTP headers". Each header is a "Name: Value" pair containing information to assist the web browser, such as the size of the text (so that the browser can check if the document is completely downloaded, or there was an error) and what is more important in our case - content type.Content type tells the browser what type the text (content) is - image, HTML page, whatever. The "Value" part of the "Content-type" header is called "MIME type" and based on it's value, the browser is instructed as to how it should process the document. "text/html" is the MIME type for HTML documents. XHTML 1.1 documents however should have "application/xhtml+xml" as the value of their "Content-type" header. So, when we say "served as", we mean "The value of the 'Content-type' HTTP header".

Link to comment
Share on other sites

Guest FirefoxRocks

Ok, here is a more simpler example (boen_robot, correct me on anything if I am wrong).You are going shopping with a stubborn idiot. He knows how to read/use the stuff he buys, but first he needs to someone to tell him what it is. He can only use(buy) stuff that is:

  • an application
  • audio
  • images
  • messages
  • text
  • video

(note there are actually a few more categories but these are the common ones)When seeing how to use the item, he must know what it is fit under for the category. So even if he knows it is an image, he needs to know what type of image to know how to look at it (or else he doesn't know how to see the picture :)) Here is what he can understand:

  • Applications
    • application/ecmascript
    • application/javascript
    • application/ogg
    • application/soap+xml
    • application/xhtml+xml

    [*]Audio (sound)

    • audio/mp4
    • audio/mpeg

    [*]Images

    • image/gif
    • image/jpeg
    • image/png

    [*]Text

    • text/html
    • text/css
    • text/plain
    • text/xml

    [*]Video

    • video/mp4

(note: there are hundreds of types of items, these are most common)So without a friend (or anyone) telling him what the item is, he can't use/read the item anyways, even though he knows how to use almost anything.Putting it into perspective: The browser is the person going shopping, you/the friend is the MIME type and the store with its items is the server.The browser doesn't understand every MIME type, for example: Firefox understands this:text/xml, application/xml, application/xhtml+xml, text/html, text/plain, image/png, */* (it will try to understand other types)Unfortunately, Internet Explorer doesn't know how to handle application/xhtml+xml, and will simply ask someone "Hey do you want this? If yes, then download it."XHTML 1.1 is designed to be "sold" only as application/xhtml+xml, so it won't work if you give it to Internet Explorer.Hope that helps,FirefoxRocks

Link to comment
Share on other sites

You are going shopping with a stubborn idiot....XHTML 1.1 is designed to be "sold" only as application/xhtml+xml, so it won't work if you give it to Internet Explorer.
Conclusion -> IE is the stubbornest most idiotic friend you could go shopping with today :) .
Link to comment
Share on other sites

You mean I can't use XHTML 1.1? :)
Yes. You can't use XHTML 1.1 in IE. You could if you're making a no-IE site, or if you adjust the server to send "text/html" for browsers that don't understand "application/xhtml+xml". There are quite a few methods for that, but those are all in general "advanced stuff".So yes. Don't use XHTML 1.1 just yet. Use XHTML 1.0 Strict.
Link to comment
Share on other sites

Guest FirefoxRocks

There is another way also, this requires a server-side language such as ASP or PHP.You can ask if the customer (browser) would like to have text/html documents or application/xhtml+xml pages. If the customer says "Ok, I will have application/xhtml+xml!", then give them XHTML 1.1. If the customer (Internet Explorer) says "I don't know what application/xhtml+xml is, so I'll go for the text/html.", then give them XHTML 1.0 Strict.A script in PHP can be written for that, so you can use XHTML 1.1, but give IE XHTML 1.0 Strict.

Link to comment
Share on other sites

There is another way also, this requires a server-side language such as ASP or PHP.You can ask if the customer (browser) would like to have text/html documents or application/xhtml+xml pages. If the customer says "Ok, I will have application/xhtml+xml!", then give them XHTML 1.1. If the customer (Internet Explorer) says "I don't know what application/xhtml+xml is, so I'll go for the text/html.", then give them XHTML 1.0 Strict.A script in PHP can be written for that, so you can use XHTML 1.1, but give IE XHTML 1.0 Strict.
Doing that is very tricky, which is why I've said it as "advanced stuff". It's really as easy as descibed above to do, and takes just as much lines in either of those languages to do it, but it's tricky to manage it.XHTML 1.1 is designed with the presumption it will always be served as application/xhtml+xml, whereas XHTML 1.0 Strict has been designed to work in both MIME types, as in the time it was created, it was not certain whether a new MIME type should be defined.There are some things valid in one which are not valid in the other. You'll have to only do things valid in both, or implement additional code to add/remove certain stuff. If you just use XHTML 1.0 Strict with both MIME types, you won't need anything more then the negotiation of the MIME types (and possibly, the addition of few explicit encoding declarations, but that would be required with or without XHTML 1.1).
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...