# .xhtml MIME Type: application/xhtml+xml

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

- MIME type: `application/xhtml+xml`
- Extensions: .xhtml
- Content-Type header: `application/xhtml+xml; charset=utf-8`
- Compress in transit: yes

## 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.

## Server configuration

### 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">
```

## FAQ

### 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

- [.html — text/html](https://www.devkult.com/mime/html.md)
- [.xml — application/xml](https://www.devkult.com/mime/xml.md)
- [.epub — application/epub+zip](https://www.devkult.com/mime/epub.md)

Open the interactive page: https://www.devkult.com/mime/xhtml