HTML
  Home arrow HTML arrow Page 2 - XHTML Explained
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

XHTML Explained
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2001-12-29

    Table of Contents:
  • XHTML Explained
  • XHTML Defined
  • XHTML Benefits
  • DTD's
  • XHTML Examples
  • Conclusion

  • 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


    XHTML Explained - XHTML Defined


    (Page 2 of 6 )

    XHTML is HTML "reformulated" to conform to the current Extensible Markup Language (XML) standard, version 1.0. Imagine taking the best parts from the HTML language and mixing them with all of the great aspects of XML… then you’re coming close to imagining the power and flexibility of XHTML.

    XHTML has much stricter language syntax that HTML, however. To create fully valid XHTML documents, they must adhere to these rules/guidelines:

    All tags must be closed

    With normal HTML documents, some browsers will still render the contents of a <table> even if you don’t close the table with a </table> tag. This allows developers to become lazy and forgetful. The tags within an XHTML document must always be nested correctly and closed properly.

    If we have the following HTML 4.0 compliant table:

    <table width="100%">

    <tr>

    <td>

    <p><b>Welcome to my page

    </td>

    </tr>

    </table>


    ... you can see straight away that the <p>, <b>, and <hr> tags aren’t closed. This is a big no-no for XHTML documents and will raise a parser error, because all tags must be closed (yes, even the <p> tag).

    The XHTML 1.0 compliant version of the table shown above looks like this:

    <table width="100%">

    <tr>

    <td>

    <p><b>Welcome to my page</b></p>

    </td>

    </tr>

    </table>


    Notice how the <p>, <b>, and <hr> tags are now closed? To close tags like <hr>, we can simply add a space and forward-slash within the tag, like this: <hr />.

    Attributes must contain quoted values

    All tag attributes, such as <p align="center"> must be enclosed within double quotes. You no longer have the choice of either single or double quotes. Also, for attributes which have no value, or aren’t quoted such as

    <option checked>1</option>

    ... you must assign a value to that attribute (even though it wont be used), and surround it in double quotes, for example:

    <option checked="checked">1</option>

    All element and attribute names must also be lower case.

    Be careful with special characters

    Because of the way XHTML documents are validated and must conform to specific rules, HTML comments like this:

    <!-- This is a comment -->

    ... as well as inline style sheets and inline JavaScript should always be removed from your XHTML document. You should store them in separate .css and .js files respectively, and reference them like this:

    <link rel="stylesheet" type="text/css" href="mystyle.css" />

    ... for style sheets, or

    <script language="JavaScript" src="mystuff.js"></script>

    ... for JavaScript files.

    If you're using other HTML characters such as <, > and & in attribute values, for example, then they should be replaced with their corresponding HTML entity representations such as "<", ">" and "&" respectively.

    Last but not least, instead of giving tags such as <input>, <select>, and <form> a value for the "name" attribute, you should use the "id" attribute instead. In XHTML documents, the "name" attribute is rendered useless, and belongs back with HTML 4.0.

    More HTML Articles
    More By Mitchell Harper


     

    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 6 hosted by Hostway