application/xhtml+xml

All MIME types
Application · Standards tree · RFC 7303.xhtml .xht

Media type / application

application/xhtml+xml

XHTML served as XML, which means strict parsing: a single malformed tag aborts the whole document.

Served inline: Rendered inline, this type executes script in the origin that served it. Never serve untrusted content under it from an origin that holds sessions — use a separate origin, or force a download with Content-Disposition: attachment.

Browser behaviour

Executes in the page

Charset

charset required

Compression

Compress in transit

Send it like this

Content-Type: application/xhtml+xml; charset=utf-8

Send `; charset=utf-8`. Without it the receiver falls back to its own default — for some text types that default is us-ascii, and any non-ASCII character then renders wrong.

Handling verdict

InlineExecutes in the page

Rendered inline, this type executes script in the origin that served it. Never serve untrusted content under it from an origin that holds sessions — use a separate origin, or force a download with Content-Disposition: attachment.

Charsetcharset required

Send `; charset=utf-8`. Without it the receiver falls back to its own default — for some text types that default is us-ascii, and any non-ASCII character then renders wrong.

CompressionCompress in transit

The payload is text-like or otherwise repetitive, so gzip or Brotli removes real bytes. Enable it at the server or CDN.

NameStandards tree

Registered with IANA through a public review process, so the name is stable and every implementation can rely on it meaning the same thing.

Anatomy of the name

RFC 6838

Top-level type

application

Application

Subtype

xhtml+xml

Registered in the standards tree.

Structured syntax

+xml

The payload is well-formed XML, so generic XML tooling — parsers, XPath, schema validators — applies.

Parameters

charset

Beyond the charset rule above, this type defines no parameters of its own.

What trips people up

2 notes
  • Scripts run exactly as in text/html, so this type carries the same XSS weight and the same upload rule.
  • A well-formedness error produces a parse error page rather than the browser's usual tolerant recovery.

Response headers

Content-Type: application/xhtml+xml; charset=utf-8
X-Content-Type-Options: nosniff
Content-Disposition: inline
Content-Security-Policy: sandbox; default-src 'none'
Vary: Accept-Encoding

nosniff stops the browser second-guessing the type you declared, which is what makes the rest of this reliable. The sandbox directive is the belt-and-braces option when the content is not fully under your control.

Server configuration

extension mapping

nginx

types {
    application/xhtml+xml  xhtml xht;
}

Apache

AddType application/xhtml+xml .xhtml .xht
AddCharset UTF-8 .xhtml .xht

Caddy

@type path *.xhtml *.xht
header @type Content-Type "application/xhtml+xml; charset=utf-8"

Extensions and other spellings

declared

File extensions

.xhtml.xht

File signature

No fixed signature — this format has no reliable magic number, so identify it by parsing rather than by the first few bytes.

Related media types

8
Familyapplication
Treestandards
Suffix+xml
Inlineactive