Dynamic HTML: The Definitive Reference, 2rd Ed.Dynamic HTML: The Definitive ReferenceSearch this book

7.2. XHTML Modularization (XHTML Basic and 1.1)

Modularization of XHTML came on the heels of the XHTML 1.0 specification. With the HTML details wrapped inside the XML (extensible) mechanism, it wasn't a very big conceptual leap to break up the large set of elements into logical groups of modules (although it took some time to hammer out the details). The XHTML modularization activity occurred somewhat independently of how the modules would potentially be packaged in future recommendations.

One set of modules were bundled together under the recommendation called XHTML Basic. In many ways, XHTML Basic is a proof of concept for the modularization activity. One of the goals of XHTML Basic was to assemble a group of modules whose elements and attributes could provide contexts for simple XHTML content—the kind of content that might be viewed in limited-display devices, such as Internet-enabled home appliances. Missing from this set, for example, is the style element, as well as all event attributes of other elements.

A more substantial group of modules found their way into the XHTML 1.1 recommendation. This recommendation represents a break from elements and practices deprecated in HTML 4 and XHTML 1.0. It does, however, provide for flexible style sheets and scripts that open up the content to dynamic content.

To give you a quick overview of the modularization of XHTML from both the global perspective and from the views of the XHTML Basic and XHTML 1.1 implementations, Table 7-1 lists the complete set of modules and indications of which modules are in each of the XHTML implementations.

Table 7-1. XHTML modularization

XHTML module

Items

XHTML Basic

XHTML 1.1

Structure[8]

body, head, html, title

Text[8]

abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strong, var

Hypertext[8]

a

List[8]

dl, dt, dd, ol, ul, li

Presentation

b, big, hr, i, small, sub, sup, tt

 

Edit

del, ins

 

Bidirectional Text

bdo

 

Basic Forms

form, input, label, select, option, textarea

 

Forms

button, fieldset, form, input, label, legend, select, optgroup, option, textarea

 

Basic Tables

caption, table, td, th, tr

 

Tables

caption, col, colgroup, table, tbody, td, tfoot, th, thead, tr

 

Image

img

Client-side Image Map

area, map

 

Server-side Image Map

ismap attribute in img element

 

Intrinsic Events

Event handler attributes

 

Scripting

noscript, script

 

Stylesheet

style

 

Style Attribute

style attribute

 

Base

base

Metainformation

meta

Link

link

Applet

applet, param

   

Object

object, param

Ruby Annotation[9]

ruby, rbc, rtc, rb, rt, rp

 

Frames

frameset, frame, noframes

   

Target

target attribute in a, area, base, link, form elements

   

Iframe

iframe

   

Name

name attribute in a, applet, form, frame, iframe, img, map elements

   

Legacy

basefont, center, dir, font, isindex, menu, s, strike, u

   

[8]This module is required for all XHTML-based DTDs.

[9]This module is from a separate Ruby Annotation recommendation. These elements are discussed in Chapter 8.

The XHTML 1.1 set of modules continues in the tradition of the XHTML 1.0 Strict DTD in that it excludes any elements or attributes that are even remotely tied to presentation or display characteristics. Thus, references to frames and targets that could lead to other windows do not have a place in XHTML 1.1 content markup. But, of course, the mainstream browsers have no problem with such constructs if you wish to deliver them in your pages. Moreover, scripts will continue to work their magic on DOM element object properties whose corresponding attributes may be missing from the DTDs. For example, an XHTML 1.1 source document could pass validation without an iframe element explicitly mentioned in the content. But a script could dynamically create and insert such an element into the document once it has reached the client.

Validating Scripts in XHTML

Core JavaScript language syntax contains some symbols (especially the & and < characters) that are common to programming languages, but are anathema to XML document validation when they appear as content inside an element (the script element in this case). The XHTML specification recommends enclosing scripts in a CDATA section, which has very specific syntax you must follow:

<script type="text/javascript">
<![CDATA[
// your JavaScript statements go in here
]]>
</script>

The problem in real life is that few browsers, including IE 6 and Netscape 6, know about this XML element, so it triggers a script error in most cases. Instead, you can continue to use the HTML comment hack that scripters have used for ages to prevent brain-dead browsers from rendering the content of <script> tags:

<script type="text/javascript">
<!--
// your JavaScript statements go in here
//-->
</script>

HTML comment tags inside elements pass even XHTML Strict validation. To explore HTML and XHTML validation, you can start with the W3C Validation Service at http://validator.w3.org/.



Library Navigation Links

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