Essential XHTML
Core Differences in XHTML from HTML
XHTML
XHTML documents are XML-based. and therefore designed to work with xml tools. Strictly conforming XHTML documents must:
- conform to the rules of one of the three DTDs
- have an html root element
- contain an xmlns definition in the root element of: http://www.w3.org/1999/xhtml
- contain a DOCTYPE declaration referencing one of the three DTDs prior to the root element
- not override any parameter entities of the declared DTD in DTD subsets
Basic Structure of an XHTML document
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>..</title>
<link rel='stylesheet' media="screen" type='text/css' href='css/style.css' />
</head>
<body>
<p>...</p>
</body>
</html>
Differences to HTML 4.0
- element and attribute names must be lower case
- non-empty elements must have end tags
- attribute values must always be quoted
- attribute value pairs must be written in full (XML does not support attribute minimization
- empty elements must have either an end tag or end with />
- user agents should strip leading and trailing whitespace, and truncate repeating whitespace characters
