What is the XHTML file format?
.xhtml files hold web pages written to the XHTML syntax - an XML-based reformulation of HTML standardized by the W3C in January 2000. XHTML is essentially an enhanced, stricter version of HTML 4, offering the same approach to writing web pages but under tighter XML rules.
The .xhtml format uses the same tags as HTML, but .xhtml pages must conform to stricter XML guidelines. Specifically, .xhtml documents must be well-formed: all tags lowercase, every attribute value quoted, every element explicitly closed (e.g. <br /> not <br>), and the whole document rooted at a single <html xmlns="http://www.w3.org/1999/xhtml"> element. They are parsed using strict XML parsers rather than the more forgiving HTML-specific parsers used for ordinary .html files - a single malformed tag halts rendering entirely when served as application/xhtml+xml.
XHTML 1.0 (2000) and 1.1 (2001) have largely given way to HTML5 for new web development, but XHTML5 - the XML serialization of HTML5 - survives. XHTML also remains the required content format for chapter documents inside EPUB e-books.
Security & safety
RISK: LOWAn .xhtml file is plain text and safe to open in a text editor. As with any web page, it can embed JavaScript that runs when opened in a browser, so a malicious local .xhtml could host a phishing page (a fake login form) or run scripts. Treat .xhtml files from e-mail or untrusted downloads like any web page: don't enter credentials into an unexpected page, and inspect a suspicious file in a text editor before letting a browser execute it.
Format details
in a nutshell- EPUB content document - Inside an .epub e-book the individual chapter/page files are XHTML, though they usually carry the .xhtml extension within the ZIP rather than appearing loose on disk.
Programs that open XHTML files
Technical details
deep spec| MIME type | application/xhtml+xml (strict XML parsing); also served as text/html (lenient HTML parsing) |
| File encoding | UTF-8 (XML default); declared in the XML declaration <?xml encoding="UTF-8"?> or HTTP Content-Type header |
| XML conformance | Must be well-formed XML: lowercase tags, all attributes quoted, every element closed, single root element |
| Namespace | Root <html> element requires xmlns="http://www.w3.org/1999/xhtml" declaration |
| DOCTYPE variants | XHTML 1.0 Strict, Transitional or Frameset DTDs; XHTML 1.1 (modularized); XHTML5 (HTML5 XML serialization) |
| Error handling | Served as application/xhtml+xml: a parse error produces a blank page; served as text/html: lenient fallback |
| EPUB usage | XHTML is the mandated content format for chapter documents inside EPUB e-books |
| Container | Plain-text XML document; no binary or ZIP wrapper |
| Typical file size | A few KB to a few hundred KB (CSS, JS and media are referenced externally, not embedded) |
| Void elements | Self-closing syntax required for void elements (e.g. <br />, <img />, <link />) |
| W3C history | XHTML 1.0 Recommendation: January 2000; XHTML 2.0 development abandoned 2009 in favour of HTML5 |
| XML declaration | Optional <?xml version="1.0" encoding="UTF-8"?> prolog; a UTF-8 BOM (EF BB BF) may precede it |
| Validation | W3C Markup Validator can validate .xhtml documents against their declared DTD |
| Released | 2000 (XHTML 1.0, W3C Recommendation) |
| Latest version | XHTML5 (the XML serialization of HTML5, part of the WHATWG HTML Living Standard); XHTML 1.1 (2001) is the last standalone W3C version |
| Open standard | Yes · royalty-free |
| Specification | www.w3.org |
XHTML conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about XHTML files.