devkult_
tools30converters34
home/mime/.xhtml

.xhtml MIME type

XHTML documenttext & code

application/xhtml+xml

HTML written as XML. Only this type makes the browser use its strict XML parser.

MIME typeapplication/xhtml+xml
Extensions.xhtml
Content-Typeapplication/xhtml+xml; charset=utf-8
Compress in transit?Yes — enable gzip or Brotli

Good to know

  • Served as text/html, an XHTML file is parsed as ordinary HTML — the XML declaration and namespace are ignored.
  • Served as application/xhtml+xml, a single well-formedness error (an unclosed tag, a stray &) stops rendering and shows an XML parsing error instead of the page.
  • EPUB books are built from XHTML content documents.

Serve .xhtml files with the right type

The response header to send:

Content-Type: application/xhtml+xml; 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)
application/xhtml+xml xhtml;
Apache (.htaccess or server config)
AddType application/xhtml+xml .xhtml
Express
res.set("Content-Type", "application/xhtml+xml; charset=utf-8");
Python
import mimetypes

mimetypes.add_type("application/xhtml+xml", ".xhtml")
HTML file input
<input type="file" accept=".xhtml,application/xhtml+xml">

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.xhtml | grep -i '^content-type:'
file --mime-type file.xhtml

Frequently asked questions

What is the MIME type for .xhtml files?

application/xhtml+xml.

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

Content-Type: application/xhtml+xml; 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