Forum Moderators: open

Message Too Old, No Replies

Share examples of bad mime types issues please!

Trying to mind my mime! ;-)

         

JAB Creations

10:13 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been making a real effort to master clientside of late and I am making an effort to mind my mimes!

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. :)

Robin_reala

10:25 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you're being confused by the type attribute (which is a hint) and the media type the server actaully sends (which is a given). For example, <img> elements don't have a type attribute - when the browser requests the image the server sends back the media type as part of the http header.

encyclo

1:41 am on Nov 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When it comes to hints, many tags offer them when pointing to external content - in fact, they are obligatory in order to validate. Examples are
<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!