Skip to content

Instantly share code, notes, and snippets.

@thanatos
Last active August 29, 2015 14:01
Show Gist options
  • Save thanatos/938cd5ee45865662c5af to your computer and use it in GitHub Desktop.
Save thanatos/938cd5ee45865662c5af to your computer and use it in GitHub Desktop.
Minimal XHTML document

Gathering info from here and The WHATWG Blog, the minimal XHTML 5 document.

(This is served with Content-Type: application/xhtml+xml.)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <meta charset="UTF-8" />
</head>
<body>
</body>
</html>

Warning

XHTML must be served as application/xhtml+xml at the HTTP layer. However, Internet Explorer only supports this in IE 9 and later. (caniuse.com) Prior to that, IE requires that XHTML be served using the erroneous Content-Type of text/html.

Note

The <!DOCTYPE html> is optional, but prevents browser quirks mode. (The WHATWG Blog)

Note

The <meta charset="UTF-8" /> isn't strictly required, but is strongly recommended. (See the MDN documentation for <meta charset> for reasons.)

Note

The XML declaration, <?xml version="1.0" encoding="UTF-8"?>, is not required as long as the document in is UTF-8 (an XML decoder will assume UTF-8). (The WHATWG Blog)

(This Gist is licensed under CC BY-SA 4.0, except for the minimal XHTML 5 document snippet, which is licensed under CC0 1.0 (public domain).)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment