/primers/html/article.php/3616166/Following-the-XHTML-Path.htm Following the XHTML Path

Following the XHTML Path

By David Jenkins

The W3C laid out the XHTML path by releasing the XHTML 1.0 (Extensible HTML) specs on January 26, 2000 with full support of all of HTML 4.0 features as well as compatibility with XML for future development. You may think of XHTML as the transition from XML (how the data is to be defined) to HTML (how the data will be displayed). For more information about XML, I highly recommend Michael Classen's XML articles on WebReference.

webreference.com/xml/ - Xploring XML on WebReference.com

The main difference between HTML and XHTML is the structure of XHTML. XHTML is a more formalized structure of HTML 4.0 supporting all HTML 4.0 features with complete CSS and DOM support. The formalized style of XHTML coding allows ease of maintenance and future additions to any XHTML Web page or site. Loose and unstructured elements are not allowed in XHTML. For example, in XHTML you must use lower case tags for all HTML attributes and elements:

<p> correct form
<P> - incorrect form

Another example of structured XHTML is unclosed elements. All XHTML elements must be closed out to produce a well-formed document. Well-formed (a term carried over from XML) simply means that all elements are nested and closed properly and follow strict guidelines in XML and XHTML. A good example is the paragraph element:

<p>your paragraph</p> - correct form
<p>your paragraph - incorrect form missing closing element.

JavaScript and CSS are not allowed in XHTML documents. The XML parser will report a error if the XHTML page contains internal CSS or JavaScript coding. Any CSS or JavaScript can be accessed through a external file. Relocate the CSS and/or JavaScript to a separate file and cross link the XHTML page to it. Web page developers will find this actually helps to modularize the components of a Web site. Anytime you need to access CSS or JavaScript, simply link to the appropriate file from your XHTML code. Most developers find this style of Web site design to be easier to maintain and modify. Modularization of XHTML is one of the future features currently under review by W3C. For further information and specifications about XHTML 1.0, please refer to the following XHTML web sites:

webreference.com/xml/column6/ - XHTML vs HTML
www.w3.org/TR/xhtml1/ - XHTML 1.0 specifications
www.w3.org/TR/xhtml11/ - XHTML specifications under review

Now is the time to double check your HTML editor. Most current HTML editors have support for XHTML. Be sure to get the latest updates and version of your HTML editor. If your editor does support XHTML, then be certain to review all documentation and suggestions on the XHTML functions. Practice converting your Web pages from HTML to XHTML. Be sure to check your XHTML by submitting your Web page to the W3C XHTML Validator. (validator.w3.org) The validator will verify that your Web page follows all XHTML guidelines and will parse correctly.

You might want to consider a XML editor. SoftQuad's XMetal 2.0 should easily transfer your Web site from a straight HTML Web site to a fast, robust XML-driven web site. XMetal will blend into your existing work flow environment allowing much greater ease of data management, creation, and presentation of any document for the internet or your intranet utilizing all the strengths of XML. I would encourage all Web developers to read Michael Cla~en's article about XML editors. His article outlines several different types of XML editors. From his review you can select the XML editor that is best suited for your specific needs.

webreference.com/xml/column8/ - XML editor review
www.softquad.com/ - XMetal 2.0 by SoftQuad

As of the writing of this article, only one browser supports XML and full support is not included. Internet Explorer 5.0 has a low level XML parser built into it. At the time of IE 5.0 release, XML was still under consideration by the W3C. Microsoft has promised full XML support in later release versions of Internet Explorer. Netscape and Opera have both pledged to support XHTML fully in the next releases of their respective browsers. By this time next year every browser will offer some XML support in some fashion, however we will have to wait and see exactly what that support will be. The nice thing about coding in XHTML now is that it does degrade nicely in all browsers. So your pages should display just fine in all version 4.0 browsers.

The one aspect that every Web page designer has wanted was cross browser compatibility. By current standards, when you code HTML you must either code separately for each browser you wish to support or you must code in such a fashion that all browsers will accept the HTML that you create. In the latter example, coding in this manner usually leads to rather boring and plain pages that may take longer then average to download.

With XML and XHTML, if the browser can parse the W3C XHTML 1.0 DTD correctly, then your page should display nicely. With XSL (the XML version of Cascading Style Sheets) and SAX2 or DOM support, you can send only what the requesting device needs. That's right - the device won't matter, regardless if it is a cell phone, pager, or desktop. The DTD will define the data for that specific device and the XML parser contained in the device will process the information correctly and prepare it for presentation to the user.

By using XML and XHTML in this manner, you should only have to code once and one time only as the proper DTD will be supported and available from the manufacture of the device. This way, you can concentrate on the data you wish to present and cross link it to the proper DTD. Your XSL or CSS will define the layout and your SAX or DOM will make the presentation dynamic if the device will support it. The future looks bright and exciting, but the first steps have just begun. So take your first steps along the XML and XHTML paths. You will be amazed at what you will be able to do.


webreference.com/xml/ - XML series by Michael Classen
www.softquad.com/ - XMetal 2.0 by SoftQuad
validator.w3.org/ - W3C's HTML and XHTML Validator
webreference.com/xml/column6/ - XHTML vs. HTML
www.w3.org/TR/xhtml1/ - for XHTML 1.0 specifications
www.w3.org/TR/xhtml11/ - XHTML specifications under review
webreference.com/xml/column8/ - XML editor review
www.w3.org/TR/xhtml-prof-req/ - Document Profiles for devices
www.w3.org/Talks/1999/12/XHTML-XML99/slide1.html - Summary

About the author:

David Jenkins is a free lance web page developer and an avid amature guitarist. His current project is a XML-driven post board site located at http://boards-net.com. You may contact David at david@boards-net.com.

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date