Tuesday, December 3, 2024

Why Switch to XHTML?

Why Switch to XHTML?

By Lee Underwood

For Web developers, the learning process never seems to end. New technologies
are constantly being developed, the manipulation of multimedia seems to know
no bounds, the proliferation of knowledge, distribution and programming languages
continue to develop and grow, and, of course, design standards are constantly
being upgraded in an effort to keep up with it all.

The coding of Web pages is one place where the learning appears endless. Depending
upon how long you’ve been coding, you may have gone through a few “upgrades”
of HTML, culminating in version 4.01. These “upgrades” are a part of the standards
set by the World Wide Web Consortium
(W3C) in an effort to develop common protocols to ensure the continued interoperability
of the World Wide Web.

The latest version of HTML is 4.01, which was a minor update of 4.0, and was
released in December, 1999. However, it’s not the current standard for coding
Web pages, according to the W3C.
The new standard (or “upgrade”) is XHTML 1.0, released January 2000, and revised
August 2002.

What is XHTML?

According to the W3C, “XHTML 1.0 is a reformulation of HTML 4.01 in XML,
and combines the strength of HTML 4 with the power of XML.
” This means that,
by using XHTML, you are adding the potential of the power of XML to your Web
pages. A discussion of XML is outside the scope of this article but there are
many resources to further your study
on the subject (just what you need, something else to study). But if all this
sounds rather complicated, it really isn’t.

Basically, XHTML is strict HTML. In the past, it was possible to get away
with a lot of sloppy coding. That now changes under XHTML:

  • a doctype indicator must be included in all documents
  • tag names must be in lowercase
  • all documents must be properly structured
  • all tags must be properly nested
  • all tags must be closed
  • all attributes must be quoted
  • the <title> tag must come first in the <head>
    tag.

There are some other rules but you get the idea. A glance at an XHTML document would basically look just like one coded in HTML 4.01:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Basic Document</title>
</head>

<body>

<p>Every good boy does well.</p>

</body>

</html>

(In order to allow for older browsers, the first line can be eliminated and a meta tag used instead.)

So Why Switch to XHTML?

For many Web developers, it’s almost certain that this question keeps popping
up. What’s the big deal? If it’s just strict HTML 4.01, why can’t I just tighten
up the code I write now? Why do I have to do what the W3C says?

It’s not so much an issue of “strict code” as it is an issue of compatibility
and conformity. For the majority of our readers, Web site development is their
life’s work; it’s what pays the bills and puts the food on the table. In that
scenario, you must be moving with the flow in order to provide the highest level
of service for your clients. Even though XML might not be a part of your current
projects, you might be working with it in the future, and it may be with the
same pages you are coding today. With a few slight changes in your workflow,
you can ease the transition to the future, making life easier for yourself and
offering additional possibilities to your clients. If a situation requiring
XHTML-coded documents presents itself down the road, you’ll be able to respond
quickly, having already laid a solid foundation with the proper coding.

As I mentioned earlier, writing XHTML is not much more difficult than writing
HTML 4.01. In fact, once you get used to it, it’s easier as the code is cleaner
and more self-explanatory. Because the format is strict, the code is clean,
and Web browsers are able to display the page quicker than one with errors and
unformatted code. Software companies are also beginning to offer editors that
are more XHTML-compliant.

XHTML provides greater control over documents viewed in a variety of browsers
and other devices, i.e. cellular phones and Braille devices, which leads to
better accessibility. Better accessibility leads to more page views. While your
clients might not be concerned with seeing their documents in anything other
than a basic Web browser, the technology of the future demands portability to
other platforms.

The Work of the World Wide Web Consortium

The W3C sets the standards for the World Wide Web. It’s a fact of life. It’s to everybody’s advantage to comply with these standards. It is these standards that Microsoft, Netscape, Mozilla, and others consult when they design new versions of their Web browsers. It is also these standards that are used by multimedia companies and others when designing new software for the Web.

According to the W3C,
“the purposes of the Consortium are to support the advancement of information
technology in the field of networking, graphics and user interfaces by evolving
the World Wide Web toward a true information infrastructure, and to encourage
cooperation in the industry through the promotion and development of standard
interfaces in the information environment known as the ‘World Wide Web.'”

The standards set by the W3C allow Web developers, designers, coders, programmers,
software manufacturers and others to all march to the same tune. In complying
with the standards, we all end up with a faster, smoother, more functional Web.
That’s why they are called “standards“. With the rapid development of
the Web, compliance with standards is a must so as to keep pace with emerging
technologies. If you want your Web pages to display correctly in the next generation
of viewing devices, it is imperative that you follow the W3C’s recommendations.

A well-written XHTML document is guaranteed to display in a standards-compliant
browser (which most are today) because of the W3C specifications. No longer
do Web sites need to display the notice: “This page is best viewed with XXX
browser”.

Onward to Bigger and Better Things!

Is it possible to continue to code in HTML 4.01 and still have viewable Web
pages? Sure, and it may be that way for some time to come. However, technology
changes rapidly. Failure to respond rapidly can be detrimental for your clients
and yourself. Changing course now allows for a smoother transition later.

As you migrate to coding in XHTML, you’re laying a foundation for the future.
As new opportunities open up, you’ll be prepared by complying with the standard
today. The World Wide Web provides opportunities that are not available in any
other realm; its possibilities seem endless. Yet, there are still rules we must
follow in order to navigate its uncharted waters.


This article originally appeared on WebReference.com.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured