What is XHTML?
XHTML (Extensible HyperText Markup Language) is a markup language that expresses HTML using XML’s stricter syntax rules, so standard XML tools can parse web pages. The W3C published XHTML 1.0 on January 26, 2000, as a reformulation of HTML 4. HTML5 superseded it, and XHTML now survives as HTML’s optional XML syntax.
More about XHTML
XHTML is HTML rewritten to follow the syntax rules of XML (Extensible Markup Language). Ordinary HTML, the markup language every website uses to structure and display content, is forgiving: browsers render a page even when its markup contains errors. An XHTML document must be well-formed, meaning free of syntax errors, so any standard XML parser can read it.
XHTML's syntax rules
XHTML 1.0, published by the W3C in 2000, reformulated HTML 4 as an application of XML. In practice, the strictness comes down to a few rules:
- All tags and attribute names are lowercase:
<p>, never<P>. - Every element is closed, so empty elements are written
<br />where HTML allows<br>. - Every attribute value is quoted:
width="300", notwidth=300. - Elements nest correctly inside a single root
<html>element.
Browsers only enforce these rules when a page is served with the application/xhtml+xml content type. Then a single well-formedness error stops the page cold: visitors see an XML parse error instead of your content. In practice, MDN notes that very few XHTML documents are served that way. Most ship as ordinary text/html, so browsers parse them with forgiving HTML parsers and the strictness never takes effect.
Is XHTML still used?
No, not for new work. XHTML 1.0 became a W3C Recommendation on January 26, 2000, and XHTML 1.1 followed on May 31, 2001. The planned successor, XHTML 2.0, never shipped: the W3C let that working group's charter expire in 2009, acknowledging HTML5 as the sole next-generation HTML standard. Today XHTML survives only as "the XML syntax for HTML" in the WHATWG HTML Living Standard.
The W3C didn't drop it arbitrarily. Browser makers rejected its decision to abandon HTML in favor of XML-based technologies: Apple, Mozilla, and Opera founded the WHATWG in 2004 to keep advancing ordinary HTML instead. Their work became HTML5, which includes both an HTML and an XML serialization, and in 2007 the W3C's own HTML working group voted to adopt HTML5 as the starting point for its next standard. XHTML 2.0 had lost before it ever shipped.
The decision rule is simple. Write new pages in HTML5, and reach for XHTML syntax only when an XML toolchain has to machine-parse your markup, for example when pages are generated or transformed by XML tools.
XHTML and WordPress themes
Current WordPress theme standards use HTML5, although some legacy themes may still contain XHTML-style markup. Per the WordPress Theme Handbook, block themes are built from HTML block templates and classic themes use PHP templates. A theme combines template files (.html in block themes, .php in classic themes) with a stylesheet (style.css), and usually JavaScript and a theme.json configuration file. Plugins are written in PHP.
WordPress even documents HTML5 as a named theme feature: add_theme_support( 'html5' ) "allows the use of HTML5 markup for the search forms, comment forms, comment lists, gallery, and caption." A theme's templates still assemble each page from a header, a content area, and a footer, via PHP template parts in classic themes or block template parts in block themes.
So skip XHTML if your goal is WordPress theme or plugin work. Learn HTML5, CSS, and PHP instead, and see our guide to building a custom WordPress theme for the full process.
Frequently Asked Questions
Powerful WordPress Hosting
Reliable, lightning-fast hosting solutions specifically optimized for WordPress. Find the perfect plan for you by clicking below.
WordPress Hosting Plans