= Media type
A <media type> identifies a data format and its intended interpretation using a type/subtype name, optionally followed by parameters. It lets a recipient choose an appropriate interpretation rather than inferring everything from a file name. Media types are used in the <Hypertext Transfer Protocol> and other Internet protocols.<Media Type Specifications and Registration Procedures>[Abstract; §§4.2–4.3, naming and parameters]{ref}
For example, `text/plain; charset=utf-8` has type `text`, subtype `plain` and a `charset` parameter naming <UTF-8>. In an <HTTP header field> such as `Content-Type: text/plain; charset=utf-8`, this describes the accompanying representation data; it is not itself that data.<HTTP Semantics>[§8.3, Content-Type and media-type syntax]{ref}
A format and a <character encoding> answer different questions. A media type can describe plain text or an image format, while a character encoding explains how text characters correspond to bytes. For example, the <PNG> format has media type `image/png`; it is not interpreted by treating all its bytes as a sequence of displayed text characters.
A file suffix is another convention. Two files with the same suffix need not actually contain the same format, and a response's type metadata need not be derived from the last characters of its <URL>. Correct interpretation requires consistent metadata and data, not merely a suggestive name.
Type/subtype tokens and parameter names have their specified case-insensitive matching rules, but parameter values follow the rules of their own definitions. Lowercasing arbitrary values is therefore not a general parsing strategy.<HTTP Semantics>[§8.3.1, media types and parameter semantics]{ref} A useful inspection separates the name, each parameter and the actual bytes being interpreted.
Back to article page