Friday, December 4, 2009

The Basics of XHTML Programming

Many of the pages that comprise internet websites are poorly written. The main reason webmasters do not realize this is because even though syntactically inadequate HTML code may exist, it could still work in most web browsers despite not following the rules. While today’s browsers are designed to deal with these inadequacies, the same cannot be said for the growing number of web-enabled mobile devices. One technology that helps to promote the clean code and compliance needed to integrate the web and mobile environment is a technology known as XHTML.
XHTML Background
As the name implies, XHTML is essentially a combination of HTML and XML. It represents a set of existing and future document types and modules that include all the elements of HTML combined with XML syntax. The first version, XHTML 1.0, was recommended by the WC3 (World Wide Web Consortium) on January 26, 2000. XHTML 1.1 was initially recommended on May 31, 20001. As of now, XHTML 5.0 is currently in development under the HTML 5.0 specification. Unlike HTML, these documents must be well structured and can therefore, actually be processed with basic XML tools. Andrew S. Tanenbaum, a professor of computer science best known for authoring the Minix operating system, said that XHTML is a “very picky” language that distinguishes itself from HTML by way of a much more strict syntax. This is assessment is right on point.
XHTML Syntax
One thing you should keep in mind is that XHTML is merely an extended version of HTML. What this means is that writing XHTML code is essentially similar to writing in HTML. The major difference is that XHTML is far more structured and more strict than its predecessor. One of the best ways to learn this language is to experiment with some old HTML code and then work to bring it up to XHTML standards. When working with the code, there are several important rules you need to remember, including the following:
- All elements must be nested correctly.
- All elements must be closed out correctly.
- All tag names must be entered in lower case characters.
- All attribute names must be entered in lower case characters.
- All attribute values must be quoted correctly.
- The name attribute is to be replaced by the id attribute
- All images and graphics must have alt (alternate) text.
- All XHTML documents require a DOCTYPE declaration along with an HTML head and body header elements.
- The title element must be included in the head element.
Learning XHTML is all about practicing and embracing discipline. If you keep this in mind, you should be able to master it in a relatively short amount of time. On the other hand, if you do not want to try manually converting an existing HTML to XHTML, you can use a software tool to perform the conversion for you. HTML Tidy is a highly recommended program because it is a free tool that helps clean your web pages. With such a handy tool at your disposal, you can get a handle on XHTML and use that knowledge to bring success to your projects.

0 التعليقات:

Post a Comment