Home arrow HTML arrow Page 4 - 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 - XHTML Syntax
(Page 4 of 7 )

The semantics of XHTML elements and their attributes are defined by the current HTML 4.01 Specification. XHTML 1.0 specifies three XML document types that correspond to the three DTDs specified in HTML 4.01: Strict, Transitional, and Frameset. These XHTML DTDs are more restrictive than HTML because XML is more restrictive in its syntax. Table 1 lists the three DTDs and the DOCTYPE tag used to specify each in a Web page.

Table 1: XHTML Document Type Definitions.

XHTML 1.0 Strict: Use when you're doing all of your formatting in Cascading Style Sheets (CSS), and not using <font> and <table> tags to control how the browser displays your documents.
        <!DOCTYPE html
                PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                "DTD/xhtml1-strict.dtd">
XHTML 1.0 Transitional: Use when you need to use presentational markup in your document, so that you don't limit your audience to users with browsers that support CSS.
        <!DOCTYPE html
                PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                "DTD/xhtml1-transitional.dtd">
 XHTML 1.0 Frameset: Use when your documents have frames
        <!DOCTYPE html
                PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
                "DTD/xhtml1-frameset.dtd">

The DOCTYPE tag doesn't affect the page by itself, it just tells the browser how to validate the XHTML code in the document.
A strictly conforming XHTML 1.0 document is restricted to tags and attributes from the XHTML 1.0 namespace. (The Strict DTD moniker shouldn't be confused with 'strictly conforming' documents. Strict DTDs specify a particular format of DTD in HTML 4.01, and strictly conforming means that it fully complies with the XHTML spec.) Such a document must meet some rather exacting requirements:
 The document must validate against one of the three DTDs.
 The root element of the document must be <html>.
 The root element of the document must designate an XHTML 1.0 namespace using the xmlns attribute.
 There must be a DOCTYPE declaration in the document prior to the root element. If present, the public identifier included in the DOCTYPE declaration must reference one of the three required DTDs.
The code in Figure 1, taken from the XHMTL proposed recommendation, is an example of a minimal XHTML 1.0 document:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml " xml:lang="en" lang="en">
 <head>
  <title>Virtual Library</title>
 </head>
 <body>
  <p>Moved to <a href="
http://vlib.org/">vlib.org</a>.</p >
 </body>
</html>

http://www.w3.org/1999/xhtml " xml:lang="en" lang="en">
 <head>
  <title>Virtual Library</title>
 </head>
 <body>
  <p>Moved to <a href="
http://vlib.org/">vlib.org</a>.</p >
 </body>
</html>


Figure 1: A minimal XHTML 1.0 document, based on the Strict DTD
The spec requires that a strictly conforming document specify the XHTML namespace using the xmlns attribute, defined to be http://www.w3.org/1999/xhtml . Figure 2 shows how the XHTML namespace can be used with another namespace, and Figure 3 shows how the XHTML 1.0 namespace can be incorporated into another XML namespace. Both these examples are from the XHTML specification. The implications of this kind of flexibility are enormous, letting you build Web documents that take advantage of various features of different namespaces.

http://www.w3.org/1999/xhtml . Figure 2 shows how the XHTML namespace can be used with another namespace, and Figure 3 shows how the XHTML 1.0 namespace can be incorporated into another XML namespace. Both these examples are from the XHTML specification. The implications of this kind of flexibility are enormous, letting you build Web documents that take advantage of various features of different namespaces.


<html xmlns=" http://www.w3.org/1999/xhtml " xml:lang="en" lang="en">
  <head>
    <title>A Math Example</title>
  </head>
  <body>
    <p>The following is MathML markup:</p>
    <math xmlns="
http://www.w3.org/1998/Math/MathML ">
      <apply> <log/>
        <logbase>
          <cn> 3 </cn>
        </logbase>
        <ci> x </ci>
      </apply>
    </math>
  </body>
</html>

http://www.w3.org/1999/xhtml " xml:lang="en" lang="en">
  <head>
    <title>A Math Example</title>
  </head>
  <body>
    <p>The following is MathML markup:</p>
    <math xmlns="
http://www.w3.org/1998/Math/MathML ">
      <apply> <log/>
        <logbase>
          <cn> 3 </cn>
        </logbase>
        <ci> x </ci>
      </apply>
    </math>
  </body>
</html>


Figure 2: Example of using the XHTML 1.0 namespace with another namespace, in this case the MathXL namespace.


<?xml version="1.0" encoding="UTF-8"?>
<!-- initially, the default namespace is "books" -->
<book xmlns='urn:loc.gov:books'
    xmlns:isbn='urn:ISBN:0-395-36341-6' xml:lang="en" lang="en">
  <title>Cheaper by the Dozen</title>
  <isbn:number>1568491379</isbn:number>
  <notes>
    <!-- make HTML the default namespace for a hypertext commentary -->
    <p xmlns='http://www.w3.org/1999/xhtml'>
        This is also available <a href="
http://www.w3.org/">online</a >.
    </p>
  </notes>
</book>

http://www.w3.org/">online</a >.
    </p>
  </notes>
</book>


Figure 3: Example of incorporating the XHTML 1.0 namespace into a custom XML namespace.


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