In this tutorial we'll go step by step studing the rules to write XHTML documents, while showing wich HTML syntaxes represent a violation of the new standards. I'll also give an idea of where XHTML come from and why there was a need for a change. Finally you'll learn to write XHTML code and check if your code is valid (i.e., it obey the standard).
Table of contentsBypass table of contents
HTML was born in 1980 as a Tim Berners-Lee project based on the concept of hypertext, that would help researchers to share information in the form of documents among the Internet. It was implemented later in 1989 in the CERN (European Organization for Nuclear Research), the largest Internet node in Europe. From there, HTML begun it's evolution that's still not finished, going trough the versions 2.0, 3.2, 4.0 and 4.01, all of them based on SGML (a meta language used to create other languages as subsets of it).
In the other hand, XML is also a meta language (used to create other languages) and is also an SGML subset, designed to be simpler to parse and process. In these days, XML is widely used in many ways to build documents and organize information (e.g., RSS, Atom, etc.) as it provides a standard way to do it that's easier to process than SGML.
In 2000, XHTML is recommended by the World Wide Web Consortium (W3C) as the new standard version of HTML, based on XML instead of SGML. This way we can consider XHTML as the result of mixing HTML and XML. Done this, all the benefits of XML are now inherited by HTML which makes it easier to parse and process, and therefore to be available in more platforms with reduced processing capacities (e.g., PDAs and cell phones).
Other motive to update HTML versions and to create the W3C is to restore the HTML's original purpose as a semantic language. Since it was implemented, many browser vendors begun to transform the standard in order to add more functionality to it. This turned it slowly into a more visual than semantic language, which inspired the W3C to make new standards intended to reverse this effect and take it back to its semantic origin. XHTML 1.1 is the most recent of this updates but there are more to come.
The rules to create an XHTML document are simple. As it's an adaption of the HTML 4.01 version (based on SGML) to the XML format (also based on SGML), most things didn't change. Only a few new rules were implemented that will make the document XML compatible and some other changes intended to turn the language into a more semantic one.
The XML declaration is a simple line and defines its version and the character encoding that your document uses. It must be declared before anything in your document, even before the document type declaration (HTML !DOCTYPE tag).
The Document Type Declaration, in XHTML documents, must be declared right under the XML declaration and should state the type of the container document. The DTDs for XHTML documents are four and depend on the version you use:
XHTML 1.0: Strict, Transitional and Frameset
The XML Namespace declaration is a simple URL and can be defined as the value of the "xmlns" attribute for the html tag.
Diseño y desarrollo: Latitud29.com