How the Web Works: XHTML

Preamble on XML

Hypertext Markup Language (HTML) is based on Standardized Generalized Markup Language (SGML). SGML is too gosh-darned complicated, so the W3C has devised Extensible Markup Language (XML). It's a metalanguage, meaning that it can be used to define other languages. Extensible Hypertext Markup Language (XHTML) is an example of just such an XML-based language. Such languages are called applications of XML.

HTML XHTML
is an application of is an application of
SGML XML

Well-formed and Valid

An important concept in XML is the idea of a well-formed document. In order to be well-formed, an XML document must meet certain minimal requirements, including:

And there's more; this list is by no means exhaustive.

Note that being well-formed is not the same as being valid. If I throw in nonsense tags, such as <nonsense>this</nonsense>, they will make my document invalid XHTML 1.0 but my document will still be well-formed.

So what's the difference? Think of well-formedness as being a general baseline and a fundamental requirement for any XML document. Validity is much more specific to a particular application of XML. Well-formed means it's written correctly; valid means it conforms to a certain, more specific set of rules.

Learn more about XML in an upcoming session on that subject.