Skip to content
BENIBIX Learn

Media Type (MIME Type)

Development📄 Files & FormatsFiles

Also known as MIME Type, Content Type, Internet Media Type

A label like image/png. It names the kind of data a server sends.

Think of it like

Think of it like the label on a box. It says what is inside, so the right person opens it.

Example

A server sends Lucy a file marked as a PDF. Her browser opens it in its PDF viewer, not as raw bytes.

Why it matters

Browsers trust this label more than the file name. A wrong label can show code as text or download a page it should show.

Definition

A MIME type is a short label that names the kind of data being sent. It has two parts with a slash, like text/html or image/png. Web servers send it with every file, in a header called Content-Type. The browser reads it to decide what to do. It may show a page, play a video or download a file. The list of official types is kept by IANA.

Example code

console
$ file --mime-type photo.png
photo.png: image/png
The file command reads the bytes and names the media type, image/png.
The labels in the round boxes are media types. A server sends one with each file.

Common mistake

Sending a script with the wrong type. A browser can refuse to run a script that is labelled as plain text.

Key takeaways

  1. 1
    Two parts. A kind and a subtype, joined by a slash.
  2. 2
    Sent in a header. Content-Type carries it on the web.
  3. 3
    Beats the name. Browsers trust the label, not the extension.

Compare

Learn it properly