MIME types in HTTP protocol
MIME types allow you to specify the type of file you are receiving so that the browser can process it correctly.
For example, the browser must understand that the received file contains CSS or an image and interpret them accordingly.
Of course, this information can most often be obtained by the file extension. For example, it is obvious that a file with the extension .css contains CSS styles. But it will be easier for the browser if the content type is specified explicitly.
The MIME type in the HTTP protocol is specified in the Content-Type header. Let's look at the most popular options.
Contents - HTML code:
Content-Type: text/html
Contents - CSS code:
Content-Type: text/css
Contents - JavaScript code:
Content-Type: text/javascript
Contents - plain text:
Content-Type: text/plain
Contents - PNG image:
Content-Type: image/png
Contents - JPG image:
Content-Type: image/jpeg
Contents - text in JSON format:
Content-Type: application/json
Contents - text in XML format:
Content-Type: text/xml