HTML
  Home arrow HTML arrow Page 4 - HTML Comes of Age: XHTML
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

HTML Comes of Age: XHTML
By: Don Kiely
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2003-03-03

    Table of Contents:
  • HTML Comes of Age: XHTML
  • Two Great Tastes that Taste Great Together
  • Extensible HTML
  • XHTML Syntax
  • Rocky Upgrade Path
  • Moving to XHTML
  • Roping the Wild, Wild Web

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    More HTML Articles
    More By Don Kiely


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT