|
On January 26th, 2000, the World Wide Web Consortium
(W3C) announced
the new standards for HTML. Surprisingly, it didn't go from HTML
4.0
to 5.0, but was the introduction to the XHTML 1.0. XHTML stands
for
eXtensible HyperText Markup Language and is meant to be the
replacement for HTML. Although it is defined as an XML application,
it is almost identical to HTML 4.01.
What's wrong with the present HTML to warrant a change? Why did
the
keepers of the 'Net decide on XHTML instead of new tags for an HTML
5.0 version?
Designers often write HTML code in a sloppy fashion. Web browsers
are
supposed to be very forgiving when rendering a page. In other words,
they still try to display the page even if some tags are nested
incorrectly or missing. This has led the browser developers to add
extra code to the browser engine so that the pages still come out
looking as they are supposed to look. However, all this code makes
the
browser a pretty big application, often between 15-18+ megs.
Now this might be fine for your PC with all the hard drive space
you
may have. However, small devices such as PDAs, cell phones,
automobiles, refrigerators, etc., cannot hold such a big browser.
Therefore, in order to be able to surf the web (and see your web
site)
with one of these devices, we need a small browser. In order to
make
the browser smaller the code must be less. That's where XHTML comes
in. It forces website designers to create clean code by strictly
enforcing what will be displayed and what will not. However, do
not be
put off by this because writing clean code will allow your pages
to be
seen by hundreds of thousands of people who use these small devices
to
surf the 'Net. The United States does not have nearly as many people
surfing the 'Net with cell phones and handhelds as Europe. I was
watching a news report on TV about the subject and they spoke about
the huge percentage of young people who are using these small devices
in ICELAND!! They said that the reason the United States was behind
Europe in surfing the 'Net with handhelds is because of the
deregulation of Ma Bell, which fragmented the infrastructure of
the
phone system. This has not been the case in most of Europe;
therefore, they are much more advanced in this endeavor than the
United States. It is estimated that by the year 2002 as much as
75% of
Internet access will be viewed by these devices. This prediction
may
or may not come true, but even at 30%-40%, that's still a hell of
a
lot of people.
Another reason that XHTML was introduced is because it allows builders
to get used to some of the facets of XML but still use most of the
HTML tags. Most people who have tried to work with XML understand
its
potential and power. However, most people generally resist change,
and
this is a good transition language. Additionally, while XHTML pages
can be viewed by today's browsers, most browsers cannot display
XML.
Of the major browsers, IE has been able to display XML pages and
the
latest version of Netscape 6.0 also has some built-in features to
handle XML.
Although these are not all the rules you must follow to createXHTML
documents, here are some of the major ones:
1) All tags must have a closing tag and be properly nested.
Therefore,
even tags such as the paragraph tag <p>, which is normally
used
singularly (without a closing tag) must now have one, i.e. </p>.
2) All the elements of the document must be in lowercase.
Therefore,
the tag <Hr> or <HR> tag would be incorrect but <hr>
would work.
3) All attribute values need to be in quotes. For example,
<body bgcolor=white> is wrong but <body bgcolor="white">
would be correct.
4) All image tags must have an <alt> attribute.
5) All <style> tags must have the type attribute.
6) You must include <html>, <head>, <title>,
and <body> tags, in that
order. They must also be closed properly.
Example of a simple XHTML page:
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en">
<head> <title>On
XHTML and Bears</title> </head>
<body>
<h1>The Three Bears </h1>
<a href = "http://www.WebProNews.com">
</a>
<p> Once upon a time,
there were three bears:
A papa bear, a mama bear and a little, bitty
furry baby bear....
</p>
</body>
</html>
Except for all the junk on the top of the document, see
how easy it is if you know HTML? Well, what is that
stuff on the top of the document? This mumbo jumbo is
code that we have to have at the beginning of our XHTML
documents. Lets examine this further:
<?xml version="1.0"
encoding="UTF-8"?>
Since XHTML is defined as an XML app, we need to put that
in to let the browser know that it is an XML document.
EXAMPLE:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
There is a big adoption from XML called a Document Type Definition
(DTD). All a
DTD is is a way of defining what is allowed and not allowed
in your document. There are three types of DTDs that you can
use with your XHTML document: Strict, Transitional, and Frameset.
Strict - Use this when you want the presentation part separated
from the structure of the document, such as using CSS
to display the page.
EXAMPLE:
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Transitional - Use this when you need to have the presentation
information
within the page so that it won't cause browsers which
don't support CSS to complain.
EXAMPLE:
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Frameset - Use this when you're using frames.
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
As you may know, a DTD helps define what is going to be contained
in the elements. Lack of space dictates that I can't cover DTDs
in greater detail in this issue. Sometimes, as you get more
sophisticated with XML, XHTML, or XSL documents, you might have
it pointing to two different DTDs. The namespace (xmlns) is used
to alleviate any confusion
if you have two elements. To learn more about namespaces, check:
http://www.rpbourret.com/xml/NamespacesFAQ.htm#q1_1
In conclusion, XHTML makes it easy to make documents which can
be seen by all kinds of new devices. Additionally, with a little
studying, you can create much more powerful pages than ever before.
Lastly, it is the bridge to XML...the future language of the
Internet.
Places to Learn More About XHTML:
http://www.xhtml.org/
http://www.w3.org/MarkUp/
http://wdvl.internet.com/Authoring/Languages/XML/XHTML/
http://www.w3schools.com/xhtml/default.asp
http://www.mozquito.org/html/lang-english/why.html
_________________
Written
by Cruise
Administrator and Webmaster
www.Web-Side.com | Cruise@Web-Side.com
|