HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
< Day Day Up > |
The new version of HTML, called XHTML, became a W3C Recommendation in January 2000. XHTML is a reformulation of HTML using XML that attempts to change the direction and use of HTML to the way it ought to be. So what does that mean? In short, rules now matter. In the past, you could feed your browser just about anything and it would render. XHTML ends all that. Now if you make a mistake, it should matter. Theoretically, a conformant browser shouldn't necessarily render the page at all, although this is highly unlikely and browsers tend to resort to a backward compatibility quirk mode to display a document. Yet despite the ability to continue to skirt the rules, you shouldn't. The gains can be significant and the rules are pretty easy to follow, particularly since we already covered them in the previous sections. Briefly, to form a valid XHTML document:
-
You must have a doctype indicator and conform to its rules. For example, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/ xhtml1/DTD/xhtml1-transitional.dtd">
-
You must have <html> , <head> , and <body> (or a <frameset> containing a <body> inside of a <noframes> tag).
-
<title> must come first in the < head> element.
-
You have to quote all your attributes, even simple ones such as <p align= "left"> .
-
You must nest your tags properly, so <i><b> is okay </b></i>, but <i><b> is not </i></b> .
-
You cannot omit optional close tags, so <p> cannot stand alone; you must have <p> and </p> .
-
Empty tags must close, so tags such as <hr> become <hr /> .
-
You must lowercase all tags and attribute names .
There's more, but this is most of them. Except for a few changes in syntax, such as the empty tag changes and the forced lowercase, just do your HTML correctly (as you should have done before).
Although XHTML doesn't appear to be a big deal, it is. Enforcing rules is going to cause problems and widespread use will take time, considering the amount of developer education, tool changes, and browser updates required. Most existing Web pages will also have to be restructured to some degree. So the big question is this: Will this really come to pass? Since the third edition of this book little actually has changed in Web development and few major sites use XHTML. However, designers are finally starting to get interested in it, particularly given the modern browsers' support for the technology.
< Day Day Up > |