HTML
  Home arrow HTML arrow Page 5 - 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  
Actuate Whitepapers 
Moblin 
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    An Introduction to XHTML - Namespace awareness


    (Page 5 of 5 )

     

    In keeping with XML, XHTML is also namespace aware and in both 1.0 and 1.1 XHTML specifications, the root or html element must contain the following namespace URL:

    <html xmlns="http://www.w3.org/1999/xhtml">

    Additional namespaces can be declared in any child or grandchild and subsequent elements of the root element in the same way. For the more simple XHTML documents, this should not be necessary, but when you get to the stage where you are adding your own XHTML elements (the X still stands for eXstensible after all!), declaring additional namespaces and their associated prefix becomes increasingly necessary. It is through this technique that two of the same elements that mean different things can be used in the same document.

    For example, your XHTML document must include a body element, but what if you want to produce a page containing numerous articles, each with a <headline> and <body> element? You could simply associate the prefix dxml (Dans XML) with your own unique namespace directly after the mandatory namespace declaration of the root element:

    Xmlns:dxml="http:www.dansworld.co.uk/mynamespace"

    Then use the body element of your articles with the assigned prefix:

    <dxml:body>This is the body of an article</dxml:body>

    When creating XHTML documents, you have to save them with a HTM extension (that is at least the common practice), therefore what you're really saving are normal HTML documents, and any elements that are not correctly formed will still work. An excellent way of testing your XHTML documents for well-formedness is to save them as XML documents instead. To illustrate what I mean, type the following code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHMTL 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Example Strict XHMTL Document</title>
      </head>
      <body>
        <h1>An example Strict XHTML Document</h1>
        <p><font face="arial">The font tag is deprecated in XHTML Strict and XHTML 1.1</p>
      </body>
    </html>

    Save the file with an HTM extension and load the page in a browser, it will work perfectly. But save the above code with an XML extension and try and load it in a browser. You will get a message advising "End tag 'p' does not match the start tag 'font'." Add the closing font tag (in the correct nesting order of course) and the document should display normally. This will not vet your documents for deprecated tags, but it should catch any syntactical errors.

    As I've stressed throughout this article, XHTML is really easy if you've worked with HTML and pretty easy even if you haven't. I've tried to cover the basic building blocks of the language, but don't be fooled, there is far more that you can do with it than I have space to describe here. XHTML is the way of the future, use it! What more can I say?


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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

    - 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
    - Custom Buttons in HTML
    - Quick Web Page Menu
    - Maximizing and Restoring HTML Images with th...
    - Maximizing and Restoring HTML Images with th...
    - Handling Hyperlinks and Images in HTML
    - Quick Start with HTML
    - HTML Tips







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