Many Web pages today are poorly written. Syntactically incorrect HTML code may work in most browsers even if it does not follow HTML rules. Browsers employ heuristics to deal with these flawed Web pages; however, Web-enabled wireless devices (such as PDAs) cannot accommodate these hefty Web browsers. The next step in HTMLs evolution comes in the form of XHTML (eXtended Hypertext Markup Language), which is basically a combination of HTML and XML.
As with XML, the World Wide Web Consortium (W3C) was the force behind XHTML development. When XML was introduced, a two-day workshop was held to discuss whether a new version of HTML in XML was needed. The answer was a resounding â€œYes.â€
The first W3C Recommendation to be published was XHTML 1.0, which reformulates HTML 4.0.1 in XML and combines the strengths of the two markup languages. The recommendation followed from earlier work on HTML 4.0.1, HTML 4.0, HTML 3.2, and HTML 2.0.
The second W3C Recommendation was XHTML Basic. It boasts of images, forms, basic tables, and object support. XHTML Basic is designed for Web clients that do not support the full set of XHTML features; examples of these clients are mobile phones, PDAs, pagers, and set-top boxes.
The third W3C Recommendation to come out was on the Modularization of XHTML. It provides a means for extending and creating subsets for XHTML. The modular design introduced by this recommendation underscores the invalidity of the â€œone-size-fits-allâ€ approach nowadays, especially with the advent of Web browsers that vary in capabilities (e.g. cellphone browser vs. desktop PC browser).
The fourth W3C Recommendation was XHTML 1.1 (Module Based XHTML). Here, a new XHTML document type is defined based on the modular design of the third XHTML Recommendation.
XHTML is a family of current and future document types and modules that contains all of the HTML 4.0.1 elements combined with XML syntax. XHTML is classified as an XML Application, and thus possess many XML features.
XHTML, described by Andrew Tanenbaum as a â€œlanguage that is Very Pickyâ€, differs itself from HTML by its stricter syntax.
The current version of XHTML that is supported by browsers is XHTML 1.0, a W3C Recommendation discussed earlier. There are three variants to XHTML 1.0:
- XHTML 1.0 Strict â€” used for exceptionally clean structural markup; the CSS (Cascading Style Sheet) language can be used with this variant to get the desired font, color, and layout effects
- XHTML 1.0 Transitional â€” best option for Web authors with webpages meant for general public access; takes advantage of XHTML features including style sheets
- XHTML 1.0 Frameset â€” used to partition the Web browser window into two or more frames
The important thing to remember here is that XHTML is extended HTML. This means that writing XHTML code is very similar to writing HTML code. The only difference lies in the fact that XHTML is more strict and more structured than its progenitor.
A good way of familiarizing yourself with XHTML is to get old HTML code and bring it up to XHTML standards. You’ll need to keep in mind several rules:
- All elements must be properly nested.
- All elements must be properly closed.
- All tag names must be in lower case.
- All attribute names must be in lower case.
- All attribute values must be properly quoted.
- The “id” attribute replaces the “name” attribute.
- All images must have alternate (“alt”) text — make the page accessible for devices that don’t load images, or screen-readers for the blind.
- All XHTML documents must have a DOCTYPE declaration, as well as the “html”, “head”, and “body” elements.
- The “title” element must be present within the “head” element.
A good hands-on tutorial on XML can be found at http://w3schools.com.
Discpiline and practice will allow you to master XHTML in no time. However, if you don’t want to convert an existing HTML document to XHTML yourself, you can use HTML Tidy, a software that does the transformation for you. Also, you can use Amaya, a web browser and editor that saves HTML documents as XHTML ones.Article Source: http://articlestub.com