A Simple XHTML Document

This is a simple XHTML document. XHTML is a reformulation of HTML 4.0 in XML. XML is the eXtensible Markup Language, and was designed to both meet the formatting need of modern web-designers, while attempting to retain the content emphasis of HTML/SGML's past. Using XHTML (and XML), a web-designer can customize the formatting of their documents to their heart's content, as well as create well-formed documents which contain information easily accessible by external programs.

Cascading Style Sheets (CSS)

The way that the designer controls the formatting of their XHTML document is through the use of a Cascading Style Sheet (CSS). A CSS is a list of formatting instructions for the XHTML browser. If you view the source of this XHTML document, you will see a "style" sub-section in the "head" section. This style sub-section is where we define our CSS. Each XHTML tag we wish to specify the format for is listed followed by formatting data enclosed in brackets.

For example, we can see that for the "p" (paragraph) tag we have chosen a black color (#000000) and have given the browser a selection of fonts to choose from (Helvetica, Arial, and Sans-Serif). These instructions are followed by a font size in points as well as a font weight. Each instruction is defined using a ":" (colon) and is seperated by a ";" (semi-colon).

These Cascading Style Sheets can also be kept externally to the XHTML document, allowing for a common CSS to be used across all the XHTML documents on a web-site. Doing this makes site-wide formatting changes as simple as modifying one CSS file.

XHTML's eXtensible Nature

One of the key features in XML is the ability of the designer to create custom tags and custom markup.

As an example, this is one of the ways to create custom markup. I have defined a "spanning" tag called "mytag". Everything inside this special markup will be formatted green as well as in a different font.

I can also use span to change the way my hyperlinks look.

Further Reading

This has been a very simple and basic example of XHTML/XML. There is really a great deal more you can do with it that I do not even touch upon here. For example, you can very easily modify the format of your tables, your itemized and enumerated lists, as well as extend totally your hyperlinks (using Xpointer and other similar new tags).

If you are interested, then you should take a look at XML: A Primer, by Simon St. Laurent. In spite of the fact that this book is more Microsoft-centric than I care for, it is still a great book on XML.

Online, be sure to take a look at the documentation at The World Wide Web Consortium (W3C). These are the guys officially in charge of the HTML/XHTML transition for web-sites. While there, be sure to read the XHTML MarkUp Specifications as well as the CSS documents.

By Samuel Hart, 2001. Permission is granted to do with this whatever you want. Code is placed in the public domain.