HTML
  Home arrow HTML arrow Page 3 - An Introduction to 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  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
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

An Introduction to XHTML
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 36
    2004-12-01

    Table of Contents:
  • An Introduction to XHTML
  • No lazy programming allowed
  • Conform to the rules
  • The table structure
  • Namespace awareness

  • 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


    An Introduction to XHTML - Conform to the rules


    (Page 3 of 5 )

    As XHTML is an application of XML, it must conform to the same rules as XML and as such, all XHTML documents must be well formed. As with XML, XHTML documents must contain a root element. This element is the HTML element and serves as the container for all other elements.  Adhering to the rules defined above will also ensure your document is well formed.

    One of the few contrasts between XML and XHTML is that XHTML documents, in addition to being well formed, must also be valid, meaning that your document must adhere to a DTD. With XML, this is of course optional. For anyone who doesn't know, a DTD or Document Type Definition is a set of syntax rules that the document associated with it must adhere to. These syntax rules are different from the structure rules explained above, in that they advise of elements that must appear, and in what order they appear. For example, the XHTML transitional DTD includes the following segment of code:

    <!ELEMENT html (head, body)>

    which declares that the Document root (the HTML element) must contain a head and a body element, in that order. These elements are child elements of the HTML element. The actual DTD is a lot more complex than the example above.

    There are three different versions of XHTML DTD that you can use in your XHTML documents; Strict, Transitional and Frameset. The Strict variant allows elements relating to document structure but does not allow most presentational elements. This version should be used in conjunction with CSS (Cascading Style Sheets) that handle the document presentation. The Transitional variant allows most elements including presentational elements, and many of the HTML 4 specification deprecated elements. This is useful if you are updating a site to be XHTML compliant but do not want to make the leap to a style sheet driven site. The frameset variant is similar to the transitional variant but also allows the use of frameset elements.

    To reference whichever DTD you plan to use in your XHTML document, simply add the following DOCTYPE declaration to your document, before the root element:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1DTD/xhtml1-strict.dtd">

    Or:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Or even:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

    Broken down into its respective parts, the above statements consist of the document type: <!DOCTYPE html, the DTD type: PUBLIC, the DTD identifier: "-//W3C//DTD XHTML 1.0 Transitional//EN", and the DTD location: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">.

    Another main difference between XML and XHTML is that in XML, the XML declaration is mandatory but in XHTML, it is optional. The W3C still strongly recommends that developers use the XML declaration in their documents for reasons of future compatibility. If used, this should be the first statement of the document with no white-space preceding it.

    Many other structures within XHTML are almost exactly the same as those in HTML 4; the linking specification, for example, is the same. In many ways it is a shame that the extensible linking structure of XML (XLINK) was not used as the base of XHTML's linking structure as we could now be using links with more than one destination, automatically traversed links and all kinds of other cool things. Instead, XHTML has inherited HTML 4's linking structure, which works in exactly the same way as it always has. Maybe this is something that future XHTML specifications will bring to the table. We can but hope.

    More HTML Articles
    More By Dan Wellman


       · The accessibility enhancing table structure elements were already introduced in HTML...
       · Having learned HTML 4.0 some time ago and then not taking much time going over the...
     

    HTML ARTICLES

    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset
    - Building Single Row Database Forms with HTML
    - Introduction to Database Forms with HTML
    - Another Look at Animation of Geographical Ma...
    - Animation of Geographical Map Regions
    - Changing and Moving Pictures with CSS
    - Clickable Geographical Map Regions
    - Gradient Creation with the HR Element
    - Text on HTML Images: Do it Yourself







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway