Differences Between HTML and XHTML
The major differences between HTML and XHTML can be broken into two groups:
syntactical and functional.Once browsers get up to speed,XHTML will not be as for-
giving as HTML.We use the future tense here because right now,XHTML functions
much like HTML in older browsers.To understand how XHTML can render in non-
XML-compatible browsers,see the section titled “Compatibility Issues and Browser
Requirements”later in this chapter.If you’re familiar with the HTML-browser debate,
you probably know two things:
Not all browsers are alike:Different browsers support different elements and
some proprietary elements of their own.Until recently,browser developers were
not concerned with standards.
Browsers let authors get away with murder,theoretically anyway.
If you want to test the previous theories,do a quick test.Create the following
XHTML document in a text editor and save it on your hard drive with a .htm
<h4>This is a heading 4</h4>
<p>Here is our paragraph</p>
Right off the bat,you shouldnotice a couple mistakes.First,there’s not a
element (which are both required for a valid HTML document).Second,
tag is not present.
After you save the document on your hard drive,open it in your browser.To open
an (X)HTML document in your browser,select File,Open,click the Browse button,
select the document name,and then click Open.The document should render in your
browser without a hitch,as shown in Figure 4.1.
With XHTML,all bets are off.When you create an XHTML document,you’re
instructing the browser to follow XML rules.If you make a mistake,such as omitting
a closing tag or typing element names in uppercase,your page will not be well formed
or valid,and the result will be an ugly error message.The terms well formedand valid
are essential to XHTML.If you do not know what they mean,see Chapter 2,“All
As mentioned earlier in this section,there are two categories of differences between
XHTML and HTML:syntactical and functional.The syntactical differences have to do
with the structure of the document (its syntax).As you become well versed in XML
(and you will because XHTML is an XML application),syntax becomes increasingly
important.When we mention XML rules,we’re talking about XML syntax rules.One
of the advantages of XML is its standardized—and yes,strict—markup.This means that
the first significant difference between HTML and XHTML is syntax.