HTMLGoodies
The ultimate html resource
Earthweb.com


About the Double-Underlined Links



Search Clipart.com:



internet.commerce
Hurricane Shutters
Promote Your Website
PDA Phones & Cases
Computer Hardware
Send Text Messages
Condos For Sale
Promotional Golf
Boat Donations
Auto Insurance Quote
Promotional Gifts
Career Education
GPS
Corporate Gifts
KVM Switches

HTML Goodies : Beyond HTML : XML: XHTML Syntax

Just because Web sites are easy to build these days, that doesn't mean it's easy to build a quality Web site that meets your business objectives.

Before developing your next Web site, or redesigning an existing site, download this Internet.com eBook to guide you through the process and plan your project, whether you're developing a site in-house or outsourcing the project.
Register now for your free Internet.com membership to download your complimentary eBook. Membership will also give you access to:

eBook library         Whitepapers         Webcasts
Newsletters         WinDrivers

HTML GOODIES TO GO NEWSLETTER


Other Related Newsletters

Serve your customers, not your servers, with VERIO FreeBSD VPS. Click here for your full-access, test-drive.

XHTML Syntax


By Vince Barnes

If you're already familiar with HTML
and would like to write XHTML,
then this is for you!

 

Sometimes I think it's harder to change from one learned system to another that is similar, but has it's differences, than it is to learn a new one from scratch.  That's because habits have formed.  "You can't teach an old dog new tricks" says the saying.  Web programmers, on the other hand, have to learn new tricks all the time because the web is an ever changing, rapidly evolving  place.

Our fundamental language, HTML, is a perfect example.  We have watched in evolve through four version releases into HTML 4.0 and now it is evolving into XHTML, the eXtensible HyperText Markup Language.  XHTML introduces new levels of power and flexibility to web pages, but does so at the expense of the forgiving nature of HTML syntax.  XHTML brings the rigorous nature of XML coding into web page coding, so for those familiar with HTML, here is a quick overview of the most obvious differences in syntax.

Document Type Definition.

Your XHTML documents will begin with XML and XHTML DTD statements like these:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

There are variations on these, but that's a subject for a more in depth look at XHTML.

CaSe Matters

While HTML allowed tags to be written in either upper or lower case (for example <BR> or <br>) XHTML only allows lower case tags.  Attribute values can, of course, be either upper or lower case, so that:

<font color="ffaacc"> ... </font>      and
<font color="FFAACC"> ... </font>

are both acceptable.
 


Closed Tags

HTML allows the omission of certain end, or closing, tags (for example <p> without a </p>) where XHTML requires all tags to be closed (<p> ..... </p>).  Tags that do not have closing tags, such as <br> and <hr> must contain a closing slash thus: <br />  <hr />  and <img src"......  " />


Tags must maintain Nesting Level

In HTML <b><i> ... </b></i> would be acceptable, whereas it is not in XHTML.   XHTML requires nesting levels to be maintained, thus:

<b><i> ... </i></b>
 

Tag Attributes must be in Quotes

The quotes are mandatory in XHTML, as in the earlier examples:

<font color="ffaacc"> ... </font>      and
<font color="FFAACC"> ... </font>


Attributes may not be minimized

HTML allows certain attribute to be minimized, such as:

<input type="checkbox" checked>

The word "checked" in this example is actually a minimized attribute.  XHTML requires attributes to be denoted in full, thus:

<input type="checkbox" checked="checked" />
 

Mandatory Head and Body tags

The <head> ..... </head>  and <body> .... </body> tags are mandatory.


Comments are CDATA

Instead of <!--  this is a comment --> comments are formatted like this:

<[CDATA[this is a comment]]>

 

Miscellaneous

Other notable rules include:

  • The <pre> tag cannot contain: img, object, big, small, sub, or sup.

  • You may not have any forms inside of other forms.

  • If your code contains a &, it must be written as &amp.

  • Any use of CSS should use all lower case lettering.

  • JavaScript should be done through external JavaScripting.

 

This overview should help you to recognize XHTML code when you see it.  In order to become an effective XHTML coder, however, you will need to study further!  Keep your eyes on HTML Goodies -- we've got more XHMTL coming!

Tools:
Add htmlgoodies.com to your favorites
Add htmlgoodies.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

IT Management Networking & Communications Web Development Hardware & Systems Software Development Earthwebnews.com



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES