devkult_
tools29converters34
home/mime/.html

.html MIME type

HTML documenttext & code

text/html

Web pages. Browsers render a response as HTML only when it's served as text/html.

MIME typetext/html
Extensions.html, .htm
Content-Typetext/html; charset=utf-8
Compress in transit?Yes — enable gzip or Brotli

Good to know

  • Declare the encoding in the header (charset=utf-8) or as the first element of <head> with <meta charset="utf-8">.
  • XHTML served as application/xhtml+xml is parsed by the stricter XML parser — one error and the page fails to render.
  • Serve user-uploaded HTML from a separate domain or as an attachment, never inline on your main origin.

Serve .html files with the right type

The response header to send:

Content-Type: text/html; charset=utf-8

Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:

nginx (inside the types block in mime.types)
text/html html htm;
Apache (.htaccess or server config)
AddType text/html .html .htm
Express
res.set("Content-Type", "text/html; charset=utf-8");
Python
import mimetypes

mimetypes.add_type("text/html", ".html")
mimetypes.add_type("text/html", ".htm")
HTML file input
<input type="file" accept=".html,.htm,text/html">

Check it

See what a server sends for a file, and what type a local file really is by its contents:

curl -sI https://example.com/file.html | grep -i '^content-type:'
file --mime-type file.html

Frequently asked questions

What is the MIME type for .html files?

text/html. The same type covers .htm.

What Content-Type header should a .html file be served with?

Content-Type: text/html; charset=utf-8. As a text format, include the charset so browsers don't guess the encoding. It compresses well, so let the server apply gzip or Brotli.

Related types

Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options