Forum Moderators: open
I'm interested in mime type stories that people would like to share to help myself and of course others become more aware of. I don't have any specific questions in general.
Not to concentrate on any particular issue but I will be addressing in the serverside development of my site is XHTML mime type for XHTML 1.1 on my site (as some of you know I am all for the latest standards) though I am still in the midst of clientside development still which is where I more curious about.
For example, do img elements require mime type declarations? What elements require them, which are optional, which are assumed automatically? Are there validators specific for mime types?
I'm curious to what others have to share. :)
<script>, <rel>, <style>... The <img> element (which predates many of the above) does not have a hint, but you need it if you want to use <object> instead (not a good idea for images, but that's another story!): <object [b]type="image/jpeg"[/b] data="http://www.example.com/mypic.jpg" width="152" height="160">Alternative content here</object> If you check out your server's configuration file (eg. the httpd.conf in Apache) you will find the definition for a myriad of filetypes. They fall into several categories, the most common on the web being
text/?, image/? and application/?. HTML is always served as text/html for example, and a JPG is served with image/jpeg - it is the server software which defines the mime type for the user agent. Sometimes there are situations where more than one mime type is used for the same kind of content, often for legacy reasons. XML is a good example - originally it was served as text/xml, but this has been deprecated in favor of application/xml and its variants such as application/rss+xml or application/xhtml+xml (both subsets of XML). One pitfall with mime types is user agent "content sniffing", where the user agent attempts to second-guess the content of the file whatever the mime type given by the server. Sometimes this is beneficial: for example, in quirks mode you can serve a CSS file as
text/plain and the result will still display. In IE the sniffing could cause problems, for example if you had a plain-text file which contained HTML markup - the browser would decide to ignore the text/plain and parse as HTML. Whilst IE6 has more or less solved the problem, Safari on the Mac has reintroduced it!