Monday, July 12, 2004
Practical differences in code, from HTML to XHTML
The following list summarizes the major code differences between HTML and XHTML:
- Including the processing instruction line (the XML prolog) is recommended, but not required:
- Doctype declaration is required:
- Namespace designation is required:
- Html, head, body, and title elements are required:
- Tags and attributes must be lowercase:
- Attribute values must be quoted:
- Non-empty tags must be terminated with a closing tag:
- Empty tags (e.g., hr, br, img) must incorporate a slash:
- Elements can't overlap—they must nest properly:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
<p class="bodytxt">
font-size="large"
<p>text</p>
<br />
<em><strong>text</strong></em>
This isn't a complete list of code differences between HTML and XHTML, but it includes most of the common issues.

