Testing

XHTML: Browser Support, Features, vs HTML

XHTML is the strict XML reformulation of HTML. Learn what XHTML is, which browsers support application/xhtml+xml, key features, and how it differs from HTML.

Author

Prince Dewani

May 6, 2026

XHTML is a W3C reformulation of HTML in XML that requires lowercase tags, quoted attributes, and closed elements. Served with the application/xhtml+xml MIME type, it works in Chrome 4+, Edge 12+, Firefox 2+, Safari 3.1+, Opera 9+, Internet Explorer 9+, Samsung Internet 4+, and Android Browser 2.1+, but not in IE 5.5 to 8.

This guide covers what XHTML is, browser support, the key features, differences from HTML, how to serve it correctly, and whether XHTML is still used.

What is XHTML?

XHTML, short for Extensible HyperText Markup Language, is a W3C specification that reformulates HTML as an XML application. It uses the namespace http://www.w3.org/1999/xhtml and enforces strict syntax rules: lowercase elements, quoted attribute values, and a closing tag for every opening tag. Browsers parse it as XML rather than as forgiving HTML.

Which browsers does XHTML support?

Most modern browsers parse XHTML when the server sends it with the application/xhtml+xml MIME type. The exception is Internet Explorer 5.5 through 8, which prompts the user to download the file instead of rendering it.

Loading browser compatibility data...

XHTML compatibility in Chrome

Chrome supports XHTML from Chrome 4 on, on Windows, macOS, Linux, ChromeOS, and Android. Pages served with the application/xhtml+xml MIME type render in XML mode and stop rendering on the first parse error.

XHTML compatibility in Edge

Microsoft Edge supports XHTML from Edge 12 on across Windows, macOS, and Linux. Edge inherits Chromium's XML parser, so behavior matches Chrome on every platform Edge ships on.

XHTML compatibility in Firefox

Firefox supports XHTML from Firefox 2 on across Windows, macOS, Linux, and Android. Mozilla's Gecko engine was one of the first to ship application/xhtml+xml and continues to render the markup in strict XML mode.

XHTML compatibility in Safari

Safari supports XHTML from Safari 3.1 on macOS and from Safari 3.2 on iOS and iPadOS. The WebKit XML parser handles application/xhtml+xml the same way across iPhone, iPad, and Mac.

XHTML compatibility in Opera

Opera supports XHTML from Opera 9 on the desktop and from Opera Mobile 10. After Opera moved to the Chromium engine, the same XML parser used by Chrome handles XHTML content in current Opera builds.

XHTML compatibility in Samsung Internet

Samsung Internet supports XHTML from Samsung Internet 4 on Android. Built on Chromium, it parses application/xhtml+xml the same way Chrome does and applies the same fail-fast error handling.

XHTML compatibility in Android Browser

The Android Browser supports XHTML from Android 2.1 on. Modern Android phones now use Chrome or a Chromium WebView, which inherits the same XML parsing behavior across the entire platform.

XHTML compatibility in Internet Explorer

Internet Explorer supports XHTML only from IE 9 on Windows. IE 5.5 to IE 8 did not support application/xhtml+xml and instead prompted the user to save the response to disk. Microsoft has retired Internet Explorer, so the supported window is IE 9 to IE 11.

Note

Note: XHTML behavior shifts across browsers and OS, especially on legacy IE and older Safari. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the key features of XHTML?

XHTML keeps the element set of HTML 4 but tightens parsing in several ways:

  • Well-formed XML: Every document must parse as valid XML. A single missing closing tag or stray ampersand stops rendering and shows an error message.
  • Lowercase tags and attributes: All element names and attribute names must use lowercase, and attribute values must be wrapped in single or double quotes.
  • Closed tags for every element: Void elements like br, img, and hr need an explicit self-closing slash, written as br /, img /, and hr /.
  • XML namespace declaration: The root html element must declare xmlns="http://www.w3.org/1999/xhtml" so the parser knows which language it is reading.
  • Fail-fast error handling: Browsers stop parsing on the first XML error and show a yellow error screen, unlike HTML's permissive recovery.
  • Polyglot markup option: XHTML 1.0 documents can be served as either text/html or application/xhtml+xml, which lets the same file work in older HTML-only browsers.
  • XML toolchain compatibility: Because XHTML is valid XML, standard XML parsers, XSLT processors, and validators can read and transform the markup directly.

What is the difference between XHTML and HTML?

XHTML is a stricter, XML-based form of HTML. The two languages share most elements but differ in syntax, parsing rules, and how browsers handle errors. The table below shows the practical differences a developer or QA engineer needs to know.

DimensionHTMLXHTML
ParserHTML parser, lenientXML parser, strict
Tag caseMixed case allowedLowercase only
Attribute quotesOptional in some casesMandatory on every value
Empty elementsbr, img, hrbr /, img /, hr /
Error handlingBrowser tries to recoverStops on the first error
MIME typetext/htmlapplication/xhtml+xml
NamespaceNot requiredxmlns="http://www.w3.org/1999/xhtml"
document.writeWorksThrows an error
...

How do you serve XHTML with the correct MIME type?

XHTML is only XHTML when the server sends it with the right Content-Type header. Adding a DOCTYPE alone does not switch the browser into XML mode. Follow these steps to serve a page as true XHTML:

  • Set the Content-Type header: Configure your server (Apache, NGINX, Express, IIS) to return Content-Type: application/xhtml+xml on the HTTP response for the document.
  • Add the XML declaration: Place the line that declares XML 1.0 with UTF-8 encoding at the very top of the file, before the DOCTYPE.
  • Declare the namespace on the root element: Use html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" as the opening tag so the parser recognizes the document language.
  • Save local files with .xhtml or .xht: For files opened from disk, browsers detect the type from the extension and switch to the XML parser without an HTTP header.
  • Verify the response: Open browser DevTools, switch to the Network tab, refresh the page, and confirm the Type column shows application/xhtml+xml on the document request.

A minimal XHTML page that follows every rule looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Sample XHTML Page</title>
  </head>
  <body>
    <h1>Hello, XHTML</h1>
    <p>Every tag is lowercased, quoted, and properly closed.</p>
    <br />
    <img src="logo.png" alt="Logo" />
  </body>
</html>

If the browser shows the source code as plain text or strips the XML declaration, the server is still sending text/html. Fix the Content-Type header before debugging anything else.

Is XHTML deprecated?

XHTML is not formally deprecated, but it has been overtaken by HTML5. The W3C halted XHTML 2.0 development and superseded the XHTML 1.0 Recommendation, pointing authors to the HTML Living Standard. XHTML5 lives on as the XML serialization of HTML5, so authors who want strict syntax can still write XHTML5 and serve it as application/xhtml+xml.

In my experience, most production sites send their pages as text/html now, even when the markup follows XHTML rules, because the HTML5 parser handles both styles without any server configuration. New projects should pick HTML5 unless an XML toolchain forces the XHTML5 serialization.

...

Citations

All XHTML version numbers, MIME type rules, and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests