HTML
  Home arrow HTML arrow Page 2 - 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  
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 - No lazy programming allowed


    (Page 2 of 5 )

    One of the most striking differences between HTML and XHTML is the conformance to pre-defined rules. HTML allows Web programmers to be fairly lazy in the way they create their mark-up; tags may be written in upper or lowercase or even a combination of the two. Tags that are considered deprecated, or no longer relevant for use, may also be used, as can browser-specific tags, like the <layer> tag in Netscape. It is very easy to get into bad coding habits when working with HTML. For example, the following code is perfectly acceptable in HTML:

    <p>Paragraph 1

    XHTML is a much stricter language. All element tags must be written in lowercase, and any empty element tags must be closed off properly.  An empty element is defined as an element that does not contain any actual text that is displayed by the browser. The <img> element is an excellent example of this. The following code snippet tells the browser to display an image called logo.gif contained in the same directory as the Web page:

    <img src="logo.gif">

    XHTML insists that any empty elements be closed in the correct manner with a space and a forward slash at the end:

    <img src="logo.gif />

    The space before the forward slash is not strictly necessary when using the latest browser versions, but for maximum compatibility with older browsers, the space should always be included. When using images in XHTML, remember that the alt attribute is a mandatory requirement, without which, your document will not validate.

    Opening and closing, or paired elements do contain text that the browser displays, like the <p> or paragraph element:

    <p>This text will appear in the main browser window</p>

    XHTML demands that all opening and closing elements are paired correctly. I hope this example easily distinguishes the difference between empty and paired elements. It also specifies that all non-empty elements have both an opening and a closing tag.

    Another difference is that all attribute values are enclosed within quotes in XHTML. In HTML quotes are not always used for attribute values, which again allows the programmer to slip into bad habits.  Additionally, all attributes must have values; in the case of attributes that by default do not have values, you need to set the value equal to the attribute itself, the noshade attribute for example, must be set in the following format:

    noshade="noshade"

    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

    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - 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...






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