HTML5 and HTML/XHTML
Both of these syntaxes are defined by the HTML5 standard. The choice of syntax is indicated by the MIME type, which is sent in the HTTP
Content-Type header. The MIME type for HTML syntax is
text/html, and the MIME type for XHTML syntax is
This example shows an HTML document and an XHTML document including the relevant HTTP headers.
HTTP/1.1 200 OK Content-Type: text/html <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>HTML</title> </head> <body> <p>I am a HTML document </body> </html>
HTTP/1.1 200 OK Content-Type: application/xhtml+xml <html xml:lang="en" xmlns="
http://www.w3.org/1999/xhtml"> <head> <title>XHTML</title> </head> <body> <p>I am a XHTML document</p> </body> </html>
MIME type versus DOCTYPE
Prior to HTML5, the two syntaxes were defined by two separate specifications: HTML 4.01 and XHTML 1.0. The XHTML1 standard claimed that you could use XHTML by declaring a special DOCTYPE. This has however never been implemented by any browser, and has been changed in the HTML5 standard. If your page is sent as
text/html, you are not using XHTML. Note that the MIME type must be located in the
Content-Type HTTP header. If you only put it into an HTML meta tag like
<meta http-equiv=…>, it will be ignored and treated like
If you serve your pages as
text/html and believe that you are writing XHTML, you may face several problems, as described in the following articles:
XHTML is supported by most modern browsers, including Firefox, Chrome, Safari, and Opera. Note, however, that Internet Explorer only supports XHTML starting with version 9. Internet Explorer 8 and older will instead show a download dialog box for unknown file types when it sees an XHTML document with the correct XHTML MIME type.
Differences from HTML