The basic syntax and semantics of HTML are defined in the HTML standard, now in its final version, 4.01. HTML matured quickly, in barely a decade. At one time, a new version would appear before you had a chance to finish reading an earlier edition of this book. Today, HTML has stopped evolving. As far as the W3C is concerned, XHTML has taken over. Now the wait is for browser manufacturers to implement the standards.
The XHTML standard currently is Version 1.0. Fortunately, XHTML Version 1.0 is, for the most part, a reconstitution of HTML Version 4.0.1. There are some differences, which we explore in Chapter 16. The popular browsers continue to support HTML documents, so there is no cause to stampede to XHTML. Do, however, start walking in that direction: a newer XHTML version, 1.1, is under consideration at the W3C, and browser developers are slowly but surely dropping nonstandard HTML features from their products.
Obviously, browser developers rely upon standards to have their software properly format and display common HTML and XHTML documents. Authors use the standards to make sure they are writing effective, correct documents that get displayed properly by the browsers.
However, standards are not always explicit; manufacturers have some leeway in how their browsers might display an element. And to complicate matters, commercial forces have pushed developers to add into their browsers nonstandard extensions meant to improve the language.
Confused? Don’t be: in this book, we explore in detail the syntax, semantics, and idioms of the HTML Version 4.01 and XHTML Version 1.0 languages, along with the many important extensions that are supported in the latest versions of the most popular browsers.
It doesn’t take an advanced degree in The Obvious to know that distinction draws attention. So, too, with browsers. Extra whizbang features can give the edge in the otherwise standardized browser market. That can be a nightmare for authors. A lot of people want you to use the latest and greatest gimmick or even useful HTML/XHTML extension. But it’s not part of the standard, and not all browsers support it. In fact, on occasion, the popular browsers support different ways of doing the same thing.
Every software vendor adheres to the technological standards; it’s embarrassing to be incompatible, and your competitors will take every opportunity to remind buyers of your product’s failure to comply, no matter how arcane or useless that standard might be. At the same time, vendors seek to make their products different from and better than the competition’s offerings. Netscape’s and Internet Explorer’s extensions to standard HTML are perfect examples of these market pressures.
Many document authors feel safe using these extended browsers’ nonstandard extensions because of their combined and commanding share of users. For better or worse, extensions to HTML in prominent browsers become part of the street version of the language, much like English slang creeping into the vocabulary of most Frenchmen, despite the best efforts of the Académie Française.
Fortunately, with HTML Version 4.0, the W3C standards caught up with the browser manufacturers. In fact, the tables turned somewhat. The many extensions to HTML that originally appeared as extensions in Netscape Navigator and Microsoft Internet Explorer are now part of the HTML 4 and XHTML 1.0 standards, and there are other parts of the new standard that are not yet features of the popular browsers.
In general, we urge you to resist using extensions unless you have a compelling and overriding reason to do so. By using them, particularly in key portions of your documents, you run the risk of losing a substantial portion of your potential readership. Sure, the Internet Explorer community is large enough to make this point moot now, but even so, you are excluding from your pages millions of people who use Netscape.
Of course, there are varying degrees of dependency on extensions. If you use some of the horizontal rule extensions, for example, most other browsers will ignore the extended attributes and render a conventional horizontal rule. On the other hand, reliance upon a number of font-size changes and text-alignment extensions to control your document’s appearance will make your document look terrible on many alternative browsers. It might not even display at all on browsers that don’t support the extensions.
We admit that it is disingenuous of us to decry the use of extensions while presenting complete descriptions of their use. In keeping with the general philosophy of the Internet, we’ll err on the side of handing out rope and guns to all interested parties while hoping you have enough smarts to keep from hanging yourself or shooting yourself in the foot.
Our advice still holds, though: use an extension only where it is necessary or very advantageous, and do so with the understanding that you are disenfranchising a portion of your audience. To that end, you might even consider providing separate, standards-based versions of your documents to accommodate users of other browsers.
The upcoming XHTML Version 1.1 provides a mechanism for extending the language in a standard way: XML modules. In fact, XHTML 1.1 is comprised of modules itself.
XHTML modules divide the HTML language into discrete document types, each defining features and functions that are parts of the language. There are separate modules for XHTML forms, text, scripting, tables, and so on — all the nondeprecated elements of XHTML 1.0.
The advantage of modules is extensibility. In addition to using the markup features from the XHTML modules normally included in the standard, the new language lets you easily blend other XML modules into your documents, extending their features and capabilities in a standard way. For instance, the W3C has defined a MathML module that provides explicit markup elements for mathematical equations that you could use in your next XHTML-based math thesis.
Modules, let alone the XHTML Version 1.1 language, are experimental and are not well supported by the popular browsers. Accordingly, we don’t recommend that you use XHTML modules just yet. For now, the subject is beyond the scope of this book. Consult the W3C web site for more details.
Get HTML & XHTML: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.