Media type · text/html
text/html
text/html is the media type for HTML documents — the format browsers parse into a page.
Key facts
| Type | text/html |
|---|---|
| Extensions | .html, .htm |
| Standard | WHATWG HTML; RFC 9110 |
| Text or binary | Text |
| Common parameter | charset=utf-8 |
What text/html is
It identifies an HTML document. A browser that receives it parses tags, builds the DOM and may execute scripts. The charset parameter or a <meta charset> declaration tells the parser how to decode bytes; UTF-8 is the recommended default and covers essentially every language.
Common mistakes
Serving HTML as text/plain shows the source instead of the page. Serving it as application/octet-stream triggers a download. A missing charset on a page with non-ASCII text produces mojibake when the browser guesses wrong. If the type is correct but the page renders as raw text, check the response header before editing the HTML — the server often overrides the file extension.
Frequently asked questions
Should text/html always use UTF-8?
UTF-8 is the recommended encoding for HTML and covers all Unicode text. If you use another charset, declare it in both the HTTP header and the document.
Why does my HTML file download instead of opening?
The server is probably sending application/octet-stream or another non-HTML type. Fix the Content-Type mapping for the extension.