home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeWeb Design in a NutshellSearch this book

31.2. Creating XHTML 1.0 Documents

Marking up a document with XHTML is virtually the same as with HTML. Documents are divided into a header and body (except framed documents, which have a frameset area), elements are marked using opening and closing tags, attributes control specific behaviors for those elements, and so on. Therefore, everything you've learned in Part II of this book applies to XHTML as well.

However, because it is an XML application, you need to play by the rigid rules of XML markup. What makes XHTML documents different from HTML 4 documents is that you need to be absolutely sure that your code is well-formed (i.e., exactly follows the syntax rules), you must declare the DTD that the document uses, and you must use the xmlns attribute to indicate the XML namespace. These issues are discussed in the following sections.

31.2.1. Tools

Because XHTML is still an emerging standard, as of this writing, none of the popular commercial web authoring tools generate XHTML standard documents automatically. This situation should change as XHTML is ushered in as the definitive standard, replacing HTML 4.01. In the meantime, Windows and UNIX users can use the W3C's browser and editing tool, Amaya, to generate XHTML documents (see http://www.w3.org/Amaya/ for more information).

Any tool that is programmed not to rewrite code it doesn't recognize (Macromedia Dreamweaver, Adobe GoLive 4 and higher, and Microsoft FrontPage 2000) should leave your XHTML-formatted tagging alone. There is an extension to Dreamweaver (available for download at http://www.macromedia.com/exchange/dreamweaver/; search for XHTML) that will generate the proper document type and namespace declarations.

Another option is to convert existing HTML documents into XHTML. You could use the command-line utility called Tidy, created by David Raggett of the W3C. Tidy cleans up many aspects of an HTML file, including converting it to well-formed XHTML. It is available at http://www.w3.org/People/Raggett/tidy/. Microsoft FrontPage 2002 can also convert selected HTML into well-formed XHTML by clicking on "Apply XML Formatting Rules." Microsoft notes, however, that while selected HTML code is converted, it does not convert the HTML page to a complete XML or XHTML document.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.