Appendix A. XHTML Reference

Due to its XML heritage, XHTML is much less forgiving than HTML has historically been (or perhaps more accurately, than HTML browsers have been). You cannot leave out closing tags or place <i> inside <a>. Attribute values must be quoted, and minimized attributes are disallowed, leading to odd constructs such as <select multiple="multiple">.

Here are some tips to keep in mind when working with XHTML:

  • XHTML documents must be well formed (closing tags required; no overlapping tags allowed).

  • Empty elements can be both opened and closed with one tag: <img src="foo"/>.

  • All elements and tags must be in lowercase.

  • Attribute values must be quoted (either with single or double quotes).

  • Attributes cannot be minimized. As an illustration, <textarea> supports a readonly attribute; in HTML 4, it would look like <textarea readonly>, but because XML does not support this syntax, with XHTML it would be <textarea readonly="readonly">.

In the element listings that follow, the location within a document in which each element may reside is indicated through one of two mechanisms. If the element has a very limited number of valid parent elements, those will be listed. Otherwise, the placement will be described as either "inline" or "block."

In turn, unless there are a limited number of valid children for a nonempty element, the content will be documented as some combination of block, inline, or text.

If an element is listed as having a block placement, it may reside directly ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.