Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
Car Donations
Prepaid Phone Card
Promotional Items
Best Price
Imprinted Gifts
Logo Design
Phone Cards
Desktop Computers
Promotional Pens
Imprinted Promotions
Web Hosting Directory
Baby Photo Contest
Free Business Cards
Corporate Awards

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Download these IBM resources today!


Webcast: Hacking 101--The Top 10 Attacks in Web Applications
Learn about the three most common web application attacks, including how they occur and what can be done to prevent them.

eKit: Web Application Security
Discover how IBM Rational AppScan Standard Edition can help you detect vulnerabilities in your Web applications. The new Web Application Security eKit provides you with valuable resources, including whitepapers, demos, and additional information on the benefits of testing your Web applications.

Tutorial: Create Secure Java Applications Productively
This is the first in a two-part tutorial series creating secure Java-based Web applications using Rational Application Developer, Data Studio and Rational AppScan.

eKit: Web 2.0 Developer
Take advantage of open, flexible Web 2.0 technologies, like social software and mash-ups. The IBM Web 2.0 Developer eKit has been updated with the latest best practices & technologies from IBM.
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Introduction to XHTML: Differences with HTML 4.

February 2, 2000

This page in XHTML 1.0!

Mandatory tags

  • The <head> and <body> elements cannot be omitted.

Tag and attribute names must be written in lower-case.

Since XML is case-sensitive, XHTML element and attribute names must be written in lowercase. You can no longer get away with what many people used to do to improve readability of code — typing the element and attribute names in uppercase and the values in lowercase. Attribute values can be any case you want. For example, the "#ffcc33" value below can also be written as "#FFCC33."

HTML: XHTML:
<TD BGCOLOR="#ffcc33"> <td bgcolor="#ffcc33">

Elements must nest, no overlapping

Most browsers don't care if you overlap elements. For example, if you have a bold tag at the end of a paragraph, it rarely matters whether you close the </b> first or the </p> first. With XML and XHTML, you need to unclose the tags in reverse order - i.e. last opened - first closed.

HTML: XHTML:
<p>Be <b>bold!</p></b> <p>Be <b>bold!</b></p>

Although overlapping is also illegal in HTML, it was widely tolerated in existing browsers. An XHTML document must be well-formed XML. It must conform to basic XML syntax. If it does not, the XML parser does not have an obligation to continue processing the document. Unlike current HTML parsers, an XML parser will not try to recover and "guess" what you meant if the syntax is wrong.

All non-empty elements must be closed

All elements must be closed, explicitly or implicitly. Many people used the <p> tag to separate paragraphs. The <p> tag is designed to mark the beginning and end of a paragraph. That makes it a "non-empty" tag since it contains the paragraph text.

HTML: XHTML:
 First paragraph<p>
 Second paragraph<p>
 <p>First paragraph</p>
 <p>Second paragraph</p>

Affected Elements: <basefont>, <body>, <colgroup>, <dd>, <dt>, <head>, <html>, <li>, <p>, <tbody>/<thead>/<tfoot>, <th>/<td>, <tr>.

Empty elements must be terminated

Empty elements (i.e. those without a closing tag) have no content. So while a <p> tag contains a paragraph, and a <b> tag contains text to be bolded, a <br> tag is "empty" because it never contains anything. Other tags like this are <hr> and <img src="valid.gif">

All empty elements must use the XML "empty tag" syntax with a trailing forward slash ("/") before the end bracket (eg. <br> becomes <br />). Note the space after the element text and the />. This is for compatibility with current browsers.

HTML: XHTML:
<hr> <hr />
<br> <br />
<input ... > <input ... />
<param ... > <param ... />
<img src="valid.gif"> <img src="valid.gif" />

Affected Elements: <area>, <base>, <br>, <col>, <frame>, <hr>, <img>, <input>, <isindex>, <link>, <meta>, <option>, <param>.

Attribute values must be quoted

No more <img ... border=0>. You now need to quote every attribute, even if it's numeric:

HTML: XHTML:
<img ... border=0> <img ... border="0" />

Attribute value pairs cannot be minimized

An attribute is minimized when there is only one possible value. XML does not allow attribute minimization. Stand-alone attributes must be expanded (eg. <td nowrap>text</td> becomes <td nowrap="nowrap">text</td>).

HTML: XHTML:
<dl compact> <dl compact="compact">
<ul compact> <ul compact="compact">
<option ... selected> <option ... selected="selected">
<td nowrap> text </td> <td nowrap="nowrap"> text </td>
<input type="radio" ... checked> <input type="radio" ... checked="checked" />
<input type="checkbox" ... checked> <input type="checkbox" ... checked="checked" />

<script> and <style> elements

In XHTML, the script and style elements are declared as having #PCDATA content. As a result, < and & will be treated as the start of markup, and entities such as &lt; and &amp; will be recognized as entity references by the XML processor to < and & respectively. Wrapping the content of the script or style element within a CDATA marked section avoids the expansion of these entities. The only delimiter that is recognized in a CDATA is the "]]>" string which ends the CDATA section.

XHTML:
 <script language="JavaScript type="text/javascript">
 <![CDATA[
	document.write("<b>Hello World!</b>");
    ]]>
 </script>
 

If your browser recognised the CDATA, you should see Hello World! above.

You can avoid using CDATA by using <script language="JavaScript" src="myscript.js"></script> to read your script code off the server, or by using <link href="mystylesheet.css" /> to load an external CSS file. This only applies when you're putting code inside these files.

Introduction to XHTML: Document Type Definitions
Introduction to XHTML, with eXamples
Introduction to XHTML, with eXamples



Up to => Home / Authoring / Languages / XML / XHTML




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


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

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers