XHTML Quick Reference Guide For XHTML 1.1

Copyright © 2002 DDCC. May be copied, distributed, and modified under the terms of the GNU Free Documentation License. This guide is provided "as is." No warranty of any kind is expressed or implied.
This guide uses only valid XHTML 1.1, of course! This site features valid CSS. This guide has been labeled with ICRA. This guide meets the Double-A conformance level of the W3C-WAI Web Content Accessibility Guidelines, version 1.0.

Introduction

I made this quick reference guide because I was tired of wading through the W3C recommendations. I hand-code my web pages, and I like to have a guide handy telling me what tags each tag can contain, what attributes each tag takes, and so forth. In the past, the W3C conveniently put all this information in the text of their recommendations. The XHTML recommendations, however, are disappointingly thin. They refer to older recommendations instead of spelling out the details anew. And the only places to find detailed rules on XHTML syntax are the DTD's, which were not meant for human consumption. Frustrated, I wrote this guide for myself.

This guide will not teach you XHTML or HTML. It is only quick reference for people who know how the languages work but who need a few reminders now and then.

This guide is based on the W3C's XHTML 1.1 (Module-Based XHTML) Recommendation, which they released on May 31, 2001. This guide itself was last edited (and checked for freshness) on April 18, 2004.

XHTML

To save me some typing, and you some reading, I have added annotations only if the tag of an element required something exceptional. Therefore, tags of elements may appear any number of times (including zero) in any order unless otherwise noted. Attributes are optional and may appear only once per tag in any order unless otherwise noted. The contents of each element (the stuff between the opening and closing tags) may appear many times or not at all unless otherwise noted. And lastly, any annotations refer only to the elements directly contained by the parent element, and not to the contents of any elements more deeply nested, unless otherwise noted. (In particular, note that certain elements cannot be inside other elements, no matter how deeply nested the prohibited element is. XML by itself does not have a way to express the "no matter how deeply nested" rule, however, so every parser will accept this fragment, for example: <a> <span> <a> </a> </span> </a>, since <a> may contain <span> and <span> may contain <a>. The XHTML specifications forbid this, even though no parser can catch this violation. Deprecated (but still valid) items are so marked.

Download This Guide

If you find this guide useful, you're welcome to download it. It comes in a bzip2 tarball.

Your Feedback is Welcome!

I intend this guide to be comprehensive and complete. And although I try my best to make sure it is absolutely correct, mistakes may have crept in. (I do write this by hand, after all.) That's why I very much appreciate your feedback. If you spot a mistake, or find something unclear, or just figured out a way to present this information better, please tell me. I also appreciate your input on whether this guide was useful or not, and whether I should update it when the next versions of HTML come out.

Proceed to the feedback form to leave comments.

Some Rambling from Yours Truly

By using modules XHTML 1.1, the W3C introduced a cleaner and more rigorous language. Unfortunately, although modules are a great way to define a language, they're a lousy way to use one. The problem is that the modules correspond to neither sets of tags, sets of similar functionality, nor sets of similar structure. One module might add attributes, another might add tags. Some modules define inline-level elements, some modules define block-level elements, and some modules do both. This obtuse sort of incremental definition makes it impossible to see on one page the properties of any given element. I do think it was a poor decision for the W3C to omit full descriptions of every tag and every attribute in the XHTML recommendation. While an SGML parser has no trouble navigating this crazy maze, a web designer who trying to wring bugs from a web page does. This is why this guide is necessary.

Many guides to HTML like to group the elements by function: for example, one chapter for forms, another for tables, yet another for scripts, and so on. However, I decided to instead group the elements structurally: tables, forms, and scripts are block-level elements, so they go into the block-level elements' section. Although the former organization is easier to learn HTML from, the latter is easier for an experienced designers who just wants to know which tag can go where.

Before I wrote this guide, and while I was working on it, I searched for other resources that fulfilled the same function. Perhaps XHTML will grow more popular in the coming months, but for now, guides to XHTML, especially to XHTML 1.1, are not as plentiful as guides to, say, HTML 4. Some of the guides that do cover XHTML seem to be merely syntax charts generated from the DTD's, and don't really attempt to organize the information to make writing web pages easier. Many were not even themselves written in XHTML. At least for now, then, this guide is filling a niche.

And Lastly, A Warning

If you are not using a recent browser, links to sections inside a page may not work. The problem is that you browser does not recognize <a id=""> as an internal anchor, recognizing instead only <a name="">. id is now the only way to name anchors (and other elements as well), so if you're developing XHTML web pages, it might be a good idea to get an up-to-date browser.