MOVING FROM HTML TO XHTML

March 10, 2008

HTML has progressed through a number of versions since its inception. The latest
standard is version 4.01, which was released by the W3C in late 1999. This is the last
release of HTML in its current state. The next generation of HTML is called the
Extensible Hypertext Markup Language (XHTML).The W3C released version 1.0

of XHTML in January 2000; a revised version was released in August 2002. As defined
in the W3C XHTML recommendation (www.w3.org/TR/xhtml1/), there are three
“flavors” of XHTML:

  • XHTML Strict—Use this when you want clean structural markup code, free
    of any markup tags associated with layout. Use XHTML Strict with
    Cascading Style Sheets to get the font, color, and layout effects you want. If
    you are beginning a new Web site, you should code to this recommendation.
  • XHTML Transitional—This type of XHTML is designed for people writing Web
    pages for the general public.The idea is to take advantage of XHTML features,
    including style sheets, but make small adjustments to your markup code for those
    viewing your pages with older browsers, which can’t understand style sheets.
  • XHTML Frameset—Use this when you want to use frames to partition the
    browser window into two or more sections.You can learn more about frames
    by reading the “Working with Frames” chapter on the Online Companion
    Web site for this book.

How do these three types of XHTML affect you as a Web developer? Your goal should
be to create code that matches the strict recommendation, using Cascading Style Sheets
for all of your display information. The benefit of the transitional type is that it allows
you to gradually migrate from existing HTML code that may still contain font and display
information to the more syntactically correct, cleaner markup code necessary to match
the strict type.

The frameset specification is important only if you plan to use frames to
partition the browser window, as described in the “Working with Frames” chapter posted
on the Online Companion Web site for this book.

The Limitations of HTML

HTML is a markup language, a structured language that lets you identify common
sections of a document such as headings, paragraphs, and lists. An HTML file includes
text and HTML markup (or element) tags that identify these sections. The HTML
markup tags indicate how the document sections appear in a browser. For example, the
<h1> element tags in the following code indicate that the text is a first-level heading:

<h1>WelcomeƒtoƒMyƒWebƒPage</h1>

The browser interprets the HTML markup elements and displays the results, hiding the
actual markup tags from the user. In the previous code, the user sees only the text
“Welcome to My Web Page” formatted as a level-one heading.

HTML adopts many features of SGML, including the cross-platform compatibility that
allows different computers to download and read the same file from the Web. Because
HTML is cross-platform compatible, it does not matter whether you are working on a
Windows PC, Macintosh, or UNIX computer.You can create HTML files and view
them on any computer platform.

HTML is not a What You See Is What You Get (WYSIWYG) layout tool. It was intended
only to express logical document structure, not formatting characteristics. Although
many current HTML editors let you work with a graphical interface, the underlying
code they create is basic HTML. However, because HTML was not designed as a layout
language, many editing programs create substandard code to accomplish a certain effect.

You cannot rely on the HTML editor’s WYSIWYG view to test your Web pages.
Because users can view the same HTML file with different browsers and on different
machines, the only way to be sure of what your audience sees is to preview your HTML
files in the browsers you anticipate your audience will use.

Despite its limitations, HTML is ideal for the Web because it is an open, nonproprietary
language that is cross-platform compatible. All of the markup tags are included with
every document and usually can be viewed through your browser. Once you are familiar
with the HTML syntax, you will find that one of the best ways to learn new coding
techniques is to find a Web page you like and view the source code. (You have a chance
to view the source code of a Web page in the Hands-on Projects at the end of this chapter.)

Get free blog up and running in minutes with Blogsome | Theme designs available here