Title: XHTML Tutorial in 3 minutes or less
Contributor: Travis M. Owens - aka (Rhelic) email@example.com
Last Update: Monday August 21 10:26 pm 2000
4 Basic Rules of XHTML
#1 Tags are case sensitsitive and its recommended you write your code in
#2 All values MUST use quotes
ie. <table border="0" cellpadding="0" cellspacing="0">
#3 All tags must have a begin and an end, if they have no ending tag, the
tag must end itself
ie. <img src="my.gif"> is now <img src="my.gif" />
<br> is now <br />
#4 All values that didn't normally have attributes now require one
ie. <hr noshade>
must now be
<hr noshade="noshade" />
Why is XHTML Important?
You are probably thinking XHTML is just silly, or just a way to make HTML
harder, well this is not the case, I will explain why XHTML is so important
to our future.
As a programmer, I realize HTML is sloppy, it doesn't require quotes around
attributes and people will use quotes in one part of a document but not
another. What this means is that a browser must read in the html, but then
analyze it. It must check if quotes are used, and it must also understand how
each tag works. That is alot of checking to do, in fact if I wrote an HTML
validator (which each browser already has to do) I would easily say the
checking code itself will reach over 100 lines.
Now lets look at XHTML, where the rules are strict, you MUST use quotes
everywhere, all tags have an ending, and if they don't, there is a 'symbol'
that says the tag is self ending. This means that any XML validator will
validate XHTML because its very generic code. From a programming aspect you
know that after an equal sign there must be a quote, a bunch of data with no
new line, and then and ending quote. I'd say I could write an XHTML validator
in like 3-5 lines of code. And if new tags were added, my XHTML validator
would not need updating because all tags follow this simple method. The XHTML
validator is independant of the code itself, its only dependant on that simple
format. While an HTML validator needs to be updated each time HTML changes.
While an XHTML browser obviously needs to be updated to support the new tag, at
least you know for sure that the validator will always pass new tags.
Ok, now for the real question... Why cares?
The thing is, a computer is so fast who cares if it takes 1 second or .05
seconds to parse HTML code. Thats true, nobody cares about a computer, but the
whole point of XHTML is to make HTML more efficient for simplier devices. That
extra time requires more CPU power and more battery power. Something small and
simple like Cell Phones and Pagers could not easily process HTML. It would take
abnormally long and use up battery life somewhat fast. XHTML is so easy to
parse that its hardware requirements are very small, it doesn't need lots of
ram, cpu or power. I mean, who wants to pay more than they have to for these
Now don't limit your thinking to these implimentations, you NEED to realize
computer to computer comminication is the future, devices will work together
more and more. Imagine your TV and VCR communicating together (this is reality
it will happen) for whatever reason, perhaps so the VCR can skip commercials,
or to know when to automatically to record your favorite program you have
watched everyday for the past month and it just so happens your not watching
it now. Obviously these devices need to use an open, clean and efficient
standard, which is obviously XML. (XHTML follows the XML ideals) Its obvious
everyone should practice using a better markup language and clean the net of
all this garbled code.
One last thing to note that XHTML code is 100% backward compatible with HTML.
This means whatever browser you have, even Netscape 1.0, will parse XHTML code
just fine. It has been standard for browsers to ignore code they dont
understand as long as its inside a tag. So that trailing " /" is simply
ignored, and to be honest, HTML was meant to have quotes around all attributes
in the first place.
Travis Owens is an Internet Developer (webdesign, e-commerence programing, perl
coder) living in central New York. He spends his free time studying up on new
technologies, feeding his two cats (What kind of webdesign doesn't have a cat?)
and throwing parties.