XHTML is same as HTML 4.01 except that it is designed to work with XML-based user agents (i.e. browsers). The name stands for eXtensible HyperText Markup Language.

Being based on XML, document must be well formed and HTML markup must satisfy strict rules.

Some of the main rules and differences in comparison to HTML 4.01 are:

  • document type (DTD) must be included before the root element and cannot be other then the three types defined (strict, transitional, frameset); also the web document must conform to rules of those declarations;
  • root element must be html;
  • xmlns (namespace) must be declared in root element;
  • elements and attributes must in lower case;
  • for non-empty elements end tags are required;
  • attribute values must be quoted;
  • empty elements must be closed of with />.

For further information follow links to Document Type Definition and eXtensible HyperText Markup Language.

In this tutorial for simplicity reasons we are not going to include declaration in our examples unless it is necessary (i.e. in this situation).

Example

XHTML code with a namespace and DTD:

 

›› go to examples ››