XHTML

XHTML is the latest World Wide Web Consortium standard as of this writing. It stands for XML Hypertext Markup Language (XHTML). It replaces HTML but is much like HTML with some additional rules to add better structure to the language. It, like HTML, has a strict, transitional, and frameset DTD.

XHTML Rules

  1. The XHTML document must be well formed. This means:
    • There must be one and only one top level element.
    • All elements must have a starting and an ending tag with matching starting and ending names. For instance documents that normally have no closing tag are normally written:

      <br>
      <hr>
      <li>

      Now must be written:

      <br />
      <hr />
      <li />

    • Element names are case sensitive.
    • Elements must be nested properly.
  2. Tags must be in lower case letters.
  3. Values of attributes must be in quotes. Formally the following would be OK:

    <A href=index.html target=_top>

    Now use the following:

    <a href="index.html" target="_top">

  4. Attributes may not be minimized.

    <table>
    <tr><td nowrap<find /var/spool -mtime +40</td></tr>
    </table>

    Becomes:

    <table>
    <tr><td nowrap="nowrap"<find /var/spool -mtime +40</td></tr>
    </table>

  5. A DTD Declaration with head and body elements must be present in the document. The DTD can be Strict, Transitional, or Frameset (for Frames). An example DTD declaration is shown below:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Of course after the DTD declaration an <html> element should exist which includes both a <head> and <body> element as is contained in a normal HTML document.

  6. The name attribute is replaced by the id attribute.

    <input type="text" name="firstname" />

    Becomes:

    <input type="text" id="firstname" />