The Sysadmin Notebook  

Sitemap

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:

  1. conform to the rules of one of the three DTDs
  2. have an html root element
  3. contain an xmlns definition in the root element of: http://www.w3.org/1999/xhtml
  4. contain a DOCTYPE declaration referencing one of the three DTDs prior to the root element
  5. 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

  1. element and attribute names must be lower case
  2. non-empty elements must have end tags
  3. attribute values must always be quoted
  4. attribute value pairs must be written in full (XML does not support attribute minimization
  5. empty elements must have either an end tag or end with />
  6. user agents should strip leading and trailing whitespace, and truncate repeating whitespace characters