Home arrow HTML arrow Page 6 - HTML Comes of Age: XHTML
HTML

HTML Comes of Age: XHTML


You know your HTML and you've got the hang of XML. Why not try XHTML. John will go through how to use Extensible HTML and its benefits.

Author Info:
By: Don Kiely
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
March 03, 2003
TABLE OF CONTENTS:
  1. · HTML Comes of Age: XHTML
  2. · Two Great Tastes that Taste Great Together
  3. · Extensible HTML
  4. · XHTML Syntax
  5. · Rocky Upgrade Path
  6. · Moving to XHTML
  7. · Roping the Wild, Wild Web

print this article
SEARCH DEVARTICLES

HTML Comes of Age: XHTML - Moving to XHTML
(Page 6 of 7 )

As with any time an irresistible new technology comes along, a Web author has to decide whether to migrate pages from HTML or start over from scratch and take full advantage of XHTML. There are a number of benefits to upgrading as well as some major pitfalls.

Because HTML is a pervasive standard and XML is becoming one, users can view carefully crafted XHTML documents in current versions of many browsers. In fact, a strictly conforming XHTML page is almost a joy to a browser because there isn't all the messy ambiguity that it finds in most Web pages built with HTML. Earlier browsers may choke on new HTML 4.01 tags, but that isn't XHTML's fault.

XHTML supports three main media types supported by most browsers, text/html, text/xml, and application/xml. Any scripting code that uses the HTML or XML document object models will work just fine in the new format.

The biggest time sinks in migrating HTML pages to XHTML will be converting tags and attributes to lower case, and adding quotes to attribute values. The cleaner the HTML code, the quicker that you'll be able to convert it to XHTML.

As this new standard sees wider adoption, new and existing Web editors are supporting XHTML and some will automatically convert existing pages. Code translators have long been the holy grail of computer science, but there is a reasonable chance that HTML to XHTML tools will actually work reliably. This is because most of the work is pretty mechanical: straightening out non-nested tags, embedding script in CDATA, including the DOCTYPE directive, etc. But some sloppy HTML code, acceptable to many old browsers, will translate poorly.

There are various tools listed on the W3C's XHTML Web site, but my favorites so far are HTML Kit and HTML Tidy working together (see the list of references on page &&). Figure 4 shows the HTML Kit freeware editor with the XMLDeveloper Web site tidied up for XHTML on the right.



Figure 4: The page at http://www.thethirdsector.com/, shown in HTML Kit, is easily and mechanically modified to comply with the XHTML standard. The biggest problem on this page is missing closing tags.

The XHTML standard has some rather rigid requirements for user agents, W3C-speak for browsers. Table 3 provides a summary of the requirements. These are generally only of interest to developers who are writing an XHTML browser, but understanding the required actions will help you as an XHTML developer understand how your content will be rendered, especially if there are any errors in the code. The W3C has various documents with guidelines for building user agents, if you want more information.

Table 3: Summary of XHTML requirements for user agent conformance.

In order to be consistent with the spec, a browser has to parse and evaluate an XHTML document for well-formedness, and if it claims to be a validating user agent, it must also validate documents against their referenced DTDs.
When a user agent processes an XHTML document as generic XML, it shall only recognize attributes of type ID as fragment identifiers. Fragment identifiers delineate portions of a document.
If a user agent encounters an element it does not recognize, it must render the element's content.
If a user agent encounters an attribute it does not recognize, it must ignore the entire attribute specification, including both the attribute and its value.
If a user agent encounters an attribute value it doesn't recognize, it must use the default attribute value.
If it encounters an entity reference for which the User Agent has processed no declaration, the entity reference should be rendered as the characters that make up the entity reference.
When rendering content, User Agents that encounter characters or character entity references that are recognized but not renderable should display the document in such a way that it is obvious to the user that normal rendering has not taken place.
The following characters are defined in [XML] as whitespace characters
Space ( )
Tab ( )
Carriage return ( )
Line feed ( )
and the user agent must comply with XHTML rules for whitespace elimination.
In order to be consistent with the spec, a browser has to parse and evaluate an XHTML document for well-formedness, and if it claims to be a validating user agent, it must also validate documents against their referenced DTDs.
When a user agent processes an XHTML document as generic XML, it shall only recognize attributes of type ID as fragment identifiers. Fragment identifiers delineate portions of a document.
If a user agent encounters an element it does not recognize, it must render the element's content.
If a user agent encounters an attribute it does not recognize, it must ignore the entire attribute specification, including both the attribute and its value.
If a user agent encounters an attribute value it doesn't recognize, it must use the default attribute value.
If it encounters an entity reference for which the User Agent has processed no declaration, the entity reference should be rendered as the characters that make up the entity reference.
When rendering content, User Agents that encounter characters or character entity references that are recognized but not renderable should display the document in such a way that it is obvious to the user that normal rendering has not taken place.
The following characters are defined in [XML] as whitespace characters
Space ( )
Tab ( )
Carriage return ( )
Line feed ( )
and the user agent must comply with XHTML rules for whitespace elimination.

blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials