Category Archives: Tutorials

How-tos, tutorials and guides (mainly on how to code for the web).


I promised a series of articles about emerging web technologies, so here is the first one.

XHTML is the next evolution of the omnipresent HTML. There aren't many obvious differences between XHTML and HTML, apart from the stricter restrictions on tag and attribute formatting. This prevents the creation of 'bad markup' that is so prevalent with HTML pages (especially ones generated by filthy software such as Microsoft Frontpage).



Would become:

<input type="checkbox" value="1" checked="checked" />

  • All attribute values have to be surrounded by double-quotation marks (")
  • All attributes and tag names have to be lower-case
  • All tags have to either self-close (e.g. <tag /> ), or be closed properly (e.g. <tag>content</tag> )
  • All attributes must have a value (e.g. checked becomes checked="checked")
  • All elements must be properly nested (e.g. you can't have a paragraph element just below another paragraph element).
  • The id attribute has replaced the name attribute for most things (including absolute CSS referencing).
  • Some elements are now mandatory: the DOCTYPE definition, the <html>, <head>, <title> (within <head>) and the <body> tags.

Apart from being easier to view and parse than HTML, XHTML is extensible. It is actually just another standard XML namespace now, instead of being an entirely different markup languge. This allows the use of XML namespaces in XHTML, and other such XML-only paradigms.


<math xmlns="">

That code could be inserted directly into an XHTML document almost anywhere (although putting it in the <head> section wouldn't be very helpful). Providing your browser is supportive of this functionality (not many are yet, as not many have inbuilt MathML/SVG functionality), this will render as proper MathML. (I will cover MathML more fully in a later article.)

One of the things that is required to create an XHTML page is the DOCTYPE definition, and a couple of adjoining tags. Here is the minimal XHTML template that cannot be reduced further:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="" xml:lang="en">
<title>XHTML 1.1 Strict</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />

Notice that I have added in the <meta> MIME type tag. This is because the above template uses XHTML 1.1 Strict, as opposed to XHTML 1.0 Transitional. XHTML 1.1 Strict has an added restriction in that it should if at all possible be sent out with the MIME type of "application/xhtml+xml" as opposed to "text/html" which is fine for HTML and XHTML 1.0. This is all wonderful and happy for decent browsers such as Mozilla Firefox, but old browsers such as Microsoft Internet Explorer 6 die when given that MIME type. This forces people to create logic at the server to decide what the browser is, and what to set the MIME type as.