Extras

Media Types

Many programs send different types of file across the Internet:

  • Browsers display HTML pages that also include style sheets, scripts, images, audio and video
  • Messaging apps are commonly used to send images, audio and video
  • Email programs can receive many kinds of attachments

Media types tell these programs the format of files and their contents so that they can be processed and/or displayed correctly.

Media types were originally defined in a specification called Multipurpose Internet Mail Extensions and were called MIME types.

The name was changed to Media Types because they were not only used in emails, but also in many other internet protocols such as HTTP, and other document formats such as HTML. They are sometimes called content types.

They are controlled by the Internet Assigned Numbers Authority (IANA), who also control IP addresses, domain names, and other internet protocols.

A Media Type is made up of two parts separated by a forward slash:

  • The type is a category of file format, such as audio, image, text, or video
  • The subtype identifies the format of the file; for example, an image could be a GIF, JPEG, PNG, or WebP

There are two classes of type: discrete and multipart. Discrete types represent a single file or medium (such as a single piece of text, music or video), whereas multipart types represent a document composed of multiple parts.

Full list of media types: https://www.iana.org/assignments/media-types/

Type/Subtype
image/jpg
text/html
audio/mp3
video/quicktime

Discrete Types

Discrete Media Types represent an individual file or medium. Below you can see the discrete types and some examples of their subtypes.


Image Media Type

The image media type is used for image or graphical data including bitmap and vector images. It is also used for animated formats of still images such as GIF.

TypeDescription
image/gifGIF image
image/jpegJPEG image
image/pngPNG image
image/svg+xmlSVG image
image/webpWebP image

Audio Media Type

The audio type is for audio files and music data.

TypeDescription
audio/mpegincludes MPEG-based formats such as MP3
audio/mp4includes formats such as M4A (non-protected audio), M4B (audiobooks / podcasts) and M4P (DRM protected audio)
audio/aacAdvanced Audio Coding format
audio/rtp-midifor transporting midi in Real-Time Protocol (RTP) packets

Video Media Type

The video type is for video files and data.

TypeDescription
video/h264h264 video
video/mp4mp4 video
video/quicktimeQuicktime video
video/rawRaw video

Text Media Type

The text type is for text-only data that is designed either for humans to read or for computers to process.

TypeDescription
text/plainPlain text
text/htmlHTML documents
text/cssCSS style sheets
text/phpPHP code
text/csvComma-separated values

Font Media Type

The font type is used to specify font or typeface data.

TypeDescription
font/ttfTrue Type font files
font/oftOpen-Type font files
font/woffWeb Open Font Format

Application Media Type

The application type is for files that are used by many types of applications, and that do not fall into one of the other types.

TypeDescription
application/javascriptJavaScript files
application/pdfPDF files
application/sqlSQL files
application/zipZIP files
application/octet-streamGeneric binary data, or unknown files

Model Media Type

The model type is for model data or 3D objects and scenes.

TypeDescription
model/vrmlVirtual Reality Modelling Language
model/vnd.collada+xmlCollada file format for 3D applications, written in XML

Example Media Type

The example type is used as a placeholder for examples that show how to use media types. They should only be used in sample code and documentation.

TypeDescription
example/formatHere, example is being used to describe a type
audio/exampleHere, example is being used to describe a subtype

Multipart Types

Multipart types are used for documents that are broken into pieces. This might be for one of two reasons:

  • The individual pieces of the document have different Media Types
  • A large field needs to be broken into parts for transmission, then re-assembled when it has been received

Below, you can see the two multipart media types.


The message type is for messages that either include other messages (for example an email that contains a forwarded email), or for very large messages that are sent in chunks.

TypeDescription
message/rfc822For forwarded messages and replied-to messages
message/partialFor parts of messages that are split up into chunks

The multipart type is used for data that will contain mutliple components that can have their own media type.

TypeDescription
multipart/form-dataUsed to send form data that may also contain files

Extra Information in Subtypes

Subtypes can use prefixes, suffixes and optional parameters to provide extra information.

Prefixes

The following three prefixes can be used at the start of a subtype. These prefixes are sometimes referred to as registration trees as they have more information about how the media types are registered with the IANA.

  • vnd. indicates that they are for use with software created by a specific vendor
  • prs. indicates that it is a personal or experimental format
  • x- indicates that they are unregistered with IANA
TypeDescription
application/vnd.apple.keynoteApple Keynote
application/vnd.ms-powerpointMicrosoft Powerpoint
image/vnd.adobe.photoshopAdobe Photoshop
application/x-x509-ca-certX.509 security certificates

Suffixes

When a file format is derived from either a standard or another file format, this can be indicated using a suffix.

To do this, the subtype is followed by a + symbol, then the name of the standard or format it is based on.

The examples show that the formats are written using Extensible Markup Language (XML).

TypeDescription
image/svg+xml Indicates that SVG is written in XML
application/mathml+xml Indicates that MathML is written in XML
application/atom+xml Indicates that the Atom feed is written in XML

Parameters

Parameters are specified by adding a semi-colon after the Media Type, followed by the name of the parameter, then an equals symbol, and then the value for the parameter.

TypeDescription
text/html;charset=UTF-8 Indicates that the HTML file uses UTF-8 character encoding
video/mp4;codecs="ac-3" Indicates that the MP4 video file uses AC-3 audio encoding

For a full list of media types see: https://www.iana.org/assignments/media-types/

NOTE: Browsers use the media type of files, not their file extension, to determine how to process them. Therefore, web servers must be configured to send the correct media type in the response's Content-Type header, otherwise the file may not be rendered or handled correctly.