Create XHTML5 Document from HTML5 document

 

Overview

it turns out XHTML5 documents are pretty simple:

note that because of XHTML5's HTML5 base,it has MathML and SVG built in to its elements structure, you simply use the elements.

IE6 does not support XHTML, which is what comes with XP, and what can be upgraded to with 2000/9x/me/nt - microsoft never upgraded these browsers though they claim to want to get these browsers out of the way, they just didn't put the effort out to really fix the real problem, which is old IE browsers still exist - maybe even 5.5.

Downloads

Download Now
xhtml-dw.zip - regex finds and replaces for dreamweaver (5/28/2012, 2KB)


steps to create XHTML5 document from HTML5 document

this method comes in handy if you are using dreamweaver or some editor which only knows about limited amounts of elements.

  1. start out with HTML5 document. see this list of HTML5 tags and this basic document structure
  2. convert all void elements (singletons, elements that should be self closed) to have a /> at the end
  3. put CDATA escaping on script and style elements: <script type="text/javascript"><!--//--><![CDATA[//><!--
    ...
    //--> and <style type="text/css"><!--/*--><![CDATA[/*><!--*/
    ...
    /*]]>*/--></style>
    basically anything that can have & and not be a named or numbered entity.
  4. convert all named entities to numeric entities if you are working with XML. in your editor you can do this by searching for the regex/regular expression &[a-zA-Z][a-zA-Z0-9]*;
  5. use <!DOCTYPE html SYSTEM "about:legacy-compat"> or <!DOCTYPE html> for DOCTYPE. DOCTYPE must be in caps and html (the root element) must be in lower case. the former is for use with XSLT.
  6. <html xmlns="http://www.w3.org/1999/xhtml"> or <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> are examples of the html tag. If you don't specify first argument, the source of the document will be served up as plain text soup.
  7. serve it up as xhtml+xml mime type, the proper mime type (Apache does not do this out of the box), see setup test server - and watch IE6 break.

to wrap all <script></script> and I think <style></style> elements in CDATA see the perils of using xhtml properly but for the best scoop on what those CDATA should look like, see Hixie's XHTML treatise on the xhtml+xml mime type and XHTML combination (standards writer at w3c)

basic HTML5 document structure

<!DOCTYPE html>
<html>
<head>
<title>
</title>
</head>
<body>
</body>
</html>

XHTML5 basic document structure for non-XML/XSLT use

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

XHTML5 basic document structure for XML/XSLT use

<!DOCTYPE html SYSTEM "about:legacy-compat">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<head>
<title>
</title>
</head>
<body>
</body>
</html>