The Differences Between HTML and XHTML.


XHTML is set to be the next step in the evolution of HTML. XHTML or "eXtensible Hyper Text Mark-up Language" is very similar to the latest version of HTML (4.0) To quote Jennifer Kyrnin of About.com "XHTML is HTML 4.0 Written in XML Format". She also writes "XML is an extensible markup language that was developed to retain the flexibility and power of HTML while reducing most of the complexity. XHTML combines the flexibility of HTML with the extensibility of XML." The "extensible" part means it can be "extended" with the addition of new tags.

Some of the Diffrences Between HTML 4 and XHTML follow.

Changes in Tags:

All tags must now be closed

<br> becomes <br />
<td> becomes <td>...</td >
<tr> becomes <tr>...</tr>
<p>... becomes <p>...</p>
<a> becomes <a /> or <a>...</a>
<html> becomes <html xmlns="http://www.w3.org/1999/xhtml">

Tags must not have missing elements

<img> tags must include alt="image description" to be correct

Tags cannot rely on defaults

correct:
<table border="0" cellpadding="0" cellspacing="0" width="88%">
Incorrect:
<table width="88%">

Tags cannot over lap

<u><b>hello</u></b> is incorrect
<u><b>hello</b></u> is correct

All tag attributes must be in quotes

<script type="text/javascript">

Tags must be lower case



Changes in Code:

XHTML documents must contain a DOCTYPE statement at the top
HTML
<html>

<head>
XHTML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

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

Style and formatting is held in a more centralized way in XHTML
HTML
<body bgcolor="lime" link="#0000ff" vlink="#808080" alink="#ff0000">
<h2 align="center"><font size="4" face="Comic Sans MS"><strong>Our History<u><br>
</u></strong></font></h2>
<h3 align="center"><font size="4" face="Comic Sans MS">Thanks so much for your interest in
Jack's Mules.</font></h3>
<h4 align="center"><font face="Comic Sans MS">Check out our services
and email us or give us a call…<br>

…we look forward to hearing from you! <IMG height=32 src="http://www.gaitedhorses.net/images/GMuleshadowclr2.gif" width=33></font></h4>
XHTML
<style type="text/css" xml:space="preserve">
/*<![CDATA[*/
body {
background-color: lime;
}
:link { color: #0000FF }
:visited { color: #808080 }
:active { color: #FF0000 }
p.c10 {font-family: Comic Sans MS; font-size: 80%}
h4.c9 {font-family: Comic Sans MS; text-align: center}
div.c8 {text-align: center}
span.c7 {color: red}
h2.c6 {font-family: Comic Sans MS; font-size: 120%; text-align: center}
h3.c5 {font-family: Comic Sans MS; font-size: 120%; text-align: center}
span.c4 {font-family: Comic Sans MS}
span.c3 {font-size: 80%}
span.c2 {font-family: Comic Sans MS; font-size: 120%}
p.c1 {text-align: center}
/*]]>*/
</style>
HTML
<p><font face="Comic Sans MS"><font color="red">Jack's Mules, Inc. </font>has been in business over
twenty years now! Jack was six years old and walked
his mule "Honey" (our "mascot"!) to Bradley's Fun Day and offered
rides for a quarter. He came home that day with his pockets full of quarters, and Jack's
Mules was born!</font><br>
</p>
XHTML
<p>Jack's Mules, Inc. has been in business over twenty years now! Jack was six years old and walked his mule "Honey" (our "mascot"!) to Bradley's Fun Day and offered rides for a quarter. He came home that day with his pockets full of quarters, and Jack's Mules was born!<br /></p>



Web Resources
http://wiki.whatwg.org/wiki/HTML_vs._XHTML
http://www.w3.org/TR/xhtml1/#xhtml
http://webdesign.about.com/cs/xhtmlxml/a/aa013100a.htm