MIME Types Explained: What They Are and Why Content-Type Matters
A practical explanation of MIME types, how servers decide which one to send, and what happens to a page or script when the type is wrong.
11 November 2026 4 min read
Every file a web server sends, whether it is an HTML page, a photograph, a stylesheet, or a JSON response from an API, is labelled with a MIME type. That label tells the browser what kind of content it is looking at and how it should be handled. Most of the time this happens invisibly and correctly, but when it goes wrong the results can range from a broken image to a browser refusing to run a script at all. Here is what a MIME type actually is, how servers work out which one to use, and what breaks when the wrong one is sent.
What a MIME type is
MIME stands for Multipurpose Internet Mail Extensions, a naming scheme that originated in email but was carried over into the web because it solved the same problem: labelling a piece of data so the receiving software knows what to do with it. On the web, the official term is now “media type,” though MIME type is still the more commonly used name and the two refer to the same thing. The list of registered media types is maintained by IANA, the Internet Assigned Numbers Authority.
A server communicates the MIME type of a response using the Content-Type HTTP header. For example, a plain HTML page is typically sent with:
Content-Type: text/html; charset=UTF-8
The type/subtype structure
A MIME type always has the same basic shape: a general type, a forward slash, then a more specific subtype. The type gives the broad category, and the subtype narrows it down to the exact format.
| MIME type | What it is |
|---|---|
| text/html | An HTML document |
| text/css | A CSS stylesheet |
| image/png | A PNG image |
| image/jpeg | A JPEG image |
| application/json | JSON data, common in API responses |
| application/pdf | A PDF document |
| text/javascript | A JavaScript file |
Some types also carry extra parameters after a semicolon, most commonly a character set, as in the text/html; charset=UTF-8 example above.
How a server decides which MIME type to send
Most web servers work out the MIME type from the file extension, using a lookup table that maps extensions to types. Apache and Nginx both ship with a default mapping file, and on a managed WordPress Hosting or VPS Hosting plan this configuration is typically already handled for you correctly out of the box. A small excerpt from a typical mime.types file looks like this:
text/html html htm shtml;
text/css css;
image/png png;
image/jpeg jpeg jpg;
text/javascript js;
application/pdf pdf;
application/json json;
When a request comes in for a file, the server looks at the extension, finds the matching entry, and sets the Content-Type header accordingly before sending the response. Dynamic applications (a PHP script, for example) instead set the header themselves in code, which is why misconfigured applications, rather than the web server, are often the actual cause of MIME problems on dynamic sites.
What goes wrong when the MIME type is misconfigured
Browsers rely heavily on the declared MIME type to decide what to do with a response, so getting it wrong causes real problems, not just cosmetic ones.
- The browser refuses to render the content correctly. A PDF served as
application/octet-streaminstead ofapplication/pdfmay be offered as a download rather than displayed inline, or an image served with the wrong image subtype may fail to display at all. - The content displays as something else entirely. A JSON API response mistakenly served as
text/htmlmay be shown as raw text or even interpreted as markup rather than parsed as structured data by the client consuming it. - Modern browsers block scripts and stylesheets outright. When a server sends the
X-Content-Type-Options: nosniffheader, browsers stop guessing and enforce the declared type strictly for scripts and stylesheets: if a script tag points to a resource that is not served with a JavaScript MIME type, the browser blocks it from executing rather than trying to run it anyway. This header exists specifically to close a security gap where browsers used to “sniff” the actual content of a file and guess its type regardless of whatContent-Typeclaimed, which attackers could exploit to get uploaded files executed as scripts.
Summary
A MIME type is simply a label, made up of a type and a subtype, that tells a browser what kind of content it is receiving. Servers usually work this out from the file extension using a mapping table, and dynamic applications set it directly in code. When the label is wrong, the consequences range from a file downloading instead of displaying, to content rendering as the wrong thing, to a modern browser refusing to execute a script or apply a stylesheet at all under strict MIME-sniffing protections. Getting the Content-Type header right is a small detail with an outsized effect on whether a page actually works.