What is MIME type "text/html"?

What is a MIME Type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

About text/html

Description

HTML (HyperText Markup Language)

The standard markup language for creating web pages and web applications.

Category

text

Details

MIME Type:text/html
Specification:RFC 2854

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:

Content-Type: text/html

HTML

In HTML, you can specify the MIME type in various elements:

<a href="file.html" type="text/html">Download file</a>

Server-side (Node.js)

Setting the Content-Type header in Node.js:

const http = require('http');

http.createServer((req, res) => {
  res.setHeader('Content-Type', 'text/html');
  res.end('Content here');
}).listen(3000);

Browser Compatibility

Most modern browsers support the text/html MIME type and will render it as a webpage.

Supported Browsers

  • Google Chrome
  • Mozilla Firefox
  • Safari
  • Microsoft Edge
  • Opera

Handling

Browsers will parse and render the HTML content, executing any embedded JavaScript and applying CSS styles.

Frequently Asked Questions

Related MIME Types

Official reference for the text/html MIME type

https://mime-type.com/text/html