text/html
textThe MIME type for HTML documents. Every browser receives text/html for web pages. Always specify charset=utf-8 to prevent legacy browsers from defaulting to ISO-8859-1 or triggering charset sniffing. The HTML spec mandates UTF-8 for new documents.
Details
text/html is defined by the WHATWG HTML Living Standard and registered with IANA. It is the most common MIME type on the web.
Always include charset: Content-Type: text/html;charset=utf-8. Without charset, legacy HTTP/1.0 clients and some proxies default to ISO-8859-1 (per RFC 2616, now superseded). The HTML5 spec mandates UTF-8 for new documents.
Alternative declarations: the HTML <meta charset='utf-8'> tag is a fallback for when the HTTP header is absent. The HTTP header takes priority.
CSP interaction: the Content-Type header interacts with Content-Security-Policy. Browsers will not execute inline scripts if CSP disallows them regardless of Content-Type.
Parameters
| Parameter | Description |
|---|---|
| charset | Character encoding. Always specify: text/html;charset=utf-8 |
Common use
Web pages served by HTTP servers
Security note
Never serve user-supplied HTML as text/html from your domain. Use text/plain or serve from a separate sandbox domain to prevent XSS.