What Is This?
The text/html MIME type indicates that the content is an HTML document. When a browser receives text/html, it parses and renders the content as a web page, executing embedded CSS and JavaScript. It is the primary content type of the World Wide Web.
Common Uses
Common Use
Serving web pages from web servers
Common Use
Email body content in HTML format
Common Use
Documentation and help pages
Common Use
Server-rendered web applications
Examples
Serve files with the text/html MIME type:
# Nginx
location ~ \.html$ {
add_header Content-Type "text/html";
}
# Apache
AddType text/html .htmlUse this MIME type in HTML or HTTP:
Content-Type: text/html <!-- HTML reference --> <link rel="preload" href="file.html" as="fetch" crossorigin>
Related Entries
More from this reference:
text/plain
The MIME type for plain text files with no formatting or markup.
text/css
The MIME type for Cascading Style Sheets used to style HTML documents.
text/javascript
The MIME type for JavaScript source files used to add interactivity to web pages.
text/csv
The MIME type for Comma-Separated Values data files.
Frequently Asked Questions
What is the difference between text/html and application/xhtml+xml?
text/html is the standard for HTML documents and is more forgiving of syntax errors. application/xhtml+xml requires strict XML parsing and will fail on malformed markup. Most websites use text/html.
Should I use text/html or text/plain for HTML?
Always use text/html. Using text/plain will cause the browser to display the HTML source code as plain text instead of rendering the page.