A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838. The Internet Assigned Numbers Authority (IANA) is responsible
for all official MIME types, and you can find the most up-to-date and complete list at their Media Types page. Warning: Browsers use the MIME type, not the file extension, to determine how to process a URL, so it's important that web servers send the correct MIME type in the response's
A MIME type most-commonly consists of just two parts: a type and a subtype, separated by a slash ( The type represents the general category into which the data type falls, such as The
subtype identifies the exact kind of data of the specified type the MIME type represents. For example, for the MIME type Each type has its own set of possible subtypes. A MIME type always has both a type and a subtype, never just one or the other. An
optional parameter can be added to provide additional details: For example, for any MIME type whose main type is MIME types are case-insensitive but are traditionally written in lowercase. The parameter values can be case-sensitive.
There are two classes of type: discrete and multipart. Discrete types are types which represent a single file or medium, such as a single text or music file, or a single video. A multipart type is one which represents a document that's comprised of multiple component parts, each of which may have its own individual MIME type; or, a multipart type may encapsulate multiple files being sent together in one transaction. For example, multipart MIME types are used
when attaching multiple files to an email. The discrete types currently registered with the IANA are: application Any kind of binary data that doesn't fall explicitly into one of the other types; either data that will be executed or interpreted in some way or binary data that requires a specific application or category of application to use. Generic binary data (or binary data whose true type is unknown) is
audio Audio or music data. Examples include example
Reserved for use as a placeholder in examples showing how to use MIME types. These should never be used outside of sample code listings and documentation. font Font/typeface data. Common
examples include image Image or graphical data including both bitmap and vector still images as well as animated versions of still image formats such as animated GIF or APNG. Common examples are model Model data for a 3D object or scene. Examples include text Text-only data including any human-readable content, source
code, or textual data such as comma-separated value (CSV) formatted data. Examples include: video Video data or files, such as MP4 movies ( For text documents
without a specific subtype, Multipart typesMultipart types indicate a category of document broken into pieces, often with different MIME types; they can also be used — especially in email scenarios — to represent multiple, separate files which are all part of the same transaction. They represent a composite document. Except for There are two multipart types: message A message that encapsulates other messages. This can be used, for instance, to represent an email that includes a forwarded message as part of its data, or to allow sending very large messages in chunks as if it were multiple messages. Examples include multipart Data that consists of multiple components which may individually have different MIME types. Examples include Important MIME types for Web developersapplication/octet-streamThis is the default for binary files. As it means
unknown binary file, browsers usually don't execute it, or even ask if it should be executed. They treat it as if the text/plainThis is the default for textual files. Even if it really means "unknown textual file," browsers assume they can display it. Note: text/css CSS files used to style a Web page must be sent with text/htmlAll HTML content should be served with this type. Alternative MIME types for XHTML (like Note: Use
text/javascript Per the
IANA Media Types registry, RFC 9239, and the HTML specification, JavaScript content should always be served using the MIME type You may find some JavaScript content incorrectly served with a Legacy JavaScript MIME types In addition to the
Note: Even though any given user agent may support any or all of these, you should only use Image types Files whose MIME type is The following image types are used commonly enough to be considered safe for use on web pages:
The Image file type and format guide provides information and recommendations about when to use the different image formats. Audio and video typesAs is the case for images, HTML doesn't mandate that web browsers support any specific file and codec types for the
Our media container formats guide provides a list of the file types that are commonly supported by web browsers, including information about what their special use cases may be, any drawbacks they have, and compatibility information, along with other details. The audio codec and video codec guides list the various codecs that web browsers often support, providing compatibility details along with technical information such as how many audio channels they support, what sort of compression is used, and what bit rates and so forth they're useful at. The codecs used by WebRTC guide expands upon this by specifically covering the codecs supported by the major web browsers, so you can choose the codecs that best cover the range of browsers you wish to support. As for MIME types of audio or video files, they typically specify the container format (file type). The optional codecs parameter can be added to the MIME type to further specify which codecs to use and what options were used to encode the media, such as codec profile, level, or other such information. The most commonly used MIME types used for web content are listed below. This isn't a complete list of all the types that may be available, however. See the media container formats guide for that.
multipart/form-dataThe As a multipart document
format, it consists of different parts, delimited by a boundary (a string starting with a double dash
The following
will send this message: POST / HTTP/1.1 Host: localhost:8000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Upgrade-Insecure-Requests: 1 Content-Type: multipart/form-data; boundary=---------------------------8721656041911415653955004498 Content-Length: 465 -----------------------------8721656041911415653955004498 Content-Disposition: form-data; name="myTextField" Test -----------------------------8721656041911415653955004498 Content-Disposition: form-data; name="myCheckBox" on -----------------------------8721656041911415653955004498 Content-Disposition: form-data; name="myFile"; filename="test.txt" Content-Type: text/plain Simple file. -----------------------------8721656041911415653955004498-- multipart/byterangesThe When the
Importance of setting the correct MIME type Most web servers send unrecognized resources as the Some common incorrect server configurations:
MIME sniffingIn the absence of a MIME type, or in certain cases where browsers believe they are incorrect, browsers may perform MIME sniffing — guessing the correct MIME type by looking at the bytes of the resource. Each browser performs MIME sniffing differently and under different circumstances. (For example, Safari will look at the file extension in the URL if the sent MIME type is unsuitable.) There are security concerns as some MIME types represent executable content. Servers can
prevent MIME sniffing by sending the Other methods of conveying document type
MIME types are not the only way to convey document type information:
See alsoWhen you send a text message that includes a video you are sending?A text message of up to 160 characters without an attached file is known as an SMS, while a text that includes a file—like a picture, video, emoji, or a website link—becomes an MMS.
What is a single point on a display screen?The correct answer is Pixel. Pixel is the smallest addressable point on a computer screen.
What images are composed of tiny squares or dots?Bitmapped graphics
Images composed of tiny squares or dots that correspond to one pixel.
Which is a system for maintain customer information and connections?A CRM system helps businesses keep customer contact details up to date, track every customer interaction, and manage customer accounts. It is designed to help businesses improve customer relationships and also Customer Lifetime Value (CLV).
|