Read an Excerpt
Chapter 1: Introduction to HTML and XHTML
...Myths about HTML and XHTMLHTML is a powerful technology, but many misconceptions exist about it. Understanding what HTML is not will certainly help page developers avoid common mistakes.
Myth: HTML Is a WYSIWYG Design Language
HTML isn't a specific, screen- or printer-precise formatting language like PostScript. Many people struggle with HTML on a daily basis, trying to create perfect layouts by using HTML elements inappropriately or by using images to make up for HTML's lack of screen and font-handling features. Other technologies, such as Cascading Style Sheets (CSS), are far better than HTML for handling presentation issues; their use returns HTML back to its structural roots.
Myth: HTML Is a Programming Language
DHTML blurs the lines between HTML as a layout language and HTML as a programming environment. However, the line should be distinct, because HTML is not a programming language. Heavily intermixing code with HTML markup in the ad-hoc manner that many DHTML authors do is far worse than trying to use HTML as a WYSIWYG markuplanguage. Programming logic can be cleanly separated in HTML in the form of script code, as discussed in Chapter 13. Unfortunately, if this separation isn't heeded, the page maintenance nightmare that results from tightly binding programming logic to content will dwarf the problems caused by misuse of HTML code for presentation purposes.
Myth: HTML Is Complete
HTML is not finished. The language does not provide all the facilities it should, even as a logical markup language. However, work is presently focused on implementing the current HTML standards under a new language, called eXtensible Markup Language (XML). Future versions of HTML will almost certainly be defined as a subset of XML. Theoretically, this is a wise decision, but the ubiquitous nature of HTML and its huge installed base suggest that considering how to extend HTML or fill in its small gaps is an incredibly important task. The W3C's current HTML Activity Statement can be found on its Web site (http://www.w3.org/MarkUp/Activity.html).
Myth: HTML Is Completely Standardized
Although the WK defines the HTML specification, in practical terms browser vendors and users often define their own de facto standards, or decide what aspects of the standards they support. While this might sound like heresy, it is true. Up until recently, when a new browser supporting a new feature was released, many companies and individuals would rush to use it, regardless of whether the feature was included in the W3C HTML standard. Today a major goal of browser vendors is to bring standard conformance to the Web, which cannot happen too soon. However, for the time being designers have to respect the past forms of markup, problems and all.
Myth: Traditional HTML Is Going Away
HTML is the foundation of the Web; with literally billions of pages in existence, not every document is going to be upgraded anytime soon. The "legacy" Web will continue for years, and HTML will always be lurking around underneath even the most advanced Web page years from now.
Myth: XHTML Will Take the Public Web By Storm
Wishful thinking, but having taught HTML for years and noticing how both editors and people build Web pages, it is very unlikely that XHTML will be the norm before the end of the year 2000, or probably even for years well beyond that. The problem is that if browsers suddenly enforced XHTML rules, few of today's existing Web documents would render at all; remember that although HTML has had rules for years, people have not really bothered much of the time to follow them. Many people learn HTML simply through imitation by viewing the source of existing pages, which are not always written correctly, and going from there. Like learning a spoken language, it is the occasional, loosely enforced rules that have allowed many document authors to quickly get involved with HTML. Like the English language, HTML is well understood and used in lots of places, but not often used perfectly. Rigor will come to the Web, but don't expect it to happen all at once.
Myth: Hand-Coding of HTML Will Continue for Decades
Although some will continue to craft pages like mechanical typesetting, as the Web editors improve and standards take root, the requirement to hand-tweak HTML layouts will diminish. Hopefully, designers will realize that knowledge of the "invisible pixel" trick is not a bankable resume bullet and instead focus on development of their talents along with a firm understanding of HTML markup.
Myth: HTML Is All You Need to Know to Create Good Web Pages Whereas HTML is the basis for Web pages, you need to know a lot more than HTML to build useful Web pages (unless the page is very simple). Document design, graphic design, and even programming often are necessary to create sophisticated Web pages. HTML serves as the foundation environment for all of these tasks, and a complete understanding of HTML technology can only aid document authors. A brief discussion of some of the other aspects of Web design is presented in the next chapter.
HTML is the markup language for building Web pages and traditionally has combined physical and logical structuring ideas. Elements-in the form of tags such as <b> and </b>-are embedded within text documents to indicate to browsers how to render pages. The rules for HTML are fairly simple. Unfortunately, these rules have not been enforced by browsers in the past. Because of this looseness, there has been a great deal of misunderstanding about the purpose of HTML, and a good portion of the documents on the Web do not conform to any particular "official" specification of HTML. The introduction of XHTML attempts to return HTML to its roots as a structural language, leaving presentational duties to other technologies such as Cascading Style Sheets. The newest version of HTML also attempts to introduce the required rigor and enforcement of syntax that will make HTML a solid foundation on which to build tomorrow's Web applications. While heavy use of strict XHTML has yet to occur on the Web, document authors following the rules presented, even using classic HTML, should be well suited to make the transition to perfectly formed documents. Before plunging in to the core elements of HTML, we'll take a look at Web development practices and project planning useful to aspiring HTML document authors.
The preceding is only a brief introduction to some of the "rules" that HTML documents tend to follow. Unfortunately, the benefit of following the rules isn't always apparent to new Web developers, because most browsers don't strictly enforce the standards. For example, although the nesting rule agrees with the formal definition of HTML, most browsers have no problem with crossed tags, or even with tags being used totally improperly. The reason for the browsers' laxity in enforcement is actually very logical: A browser would display nonstop error messages if it displayed a message every time that it encountered a slightly miscoded Web page! Nevertheless, don't use the browsers' laxity in enforcing HTML's "rules" as an excuse to misuse HTML or sloppily code a page. Standards impose specific structural requirements on documents, and as the Web becomes increasingly more complicated and technologies such as the eXtensible Markup Language (XML) are adopted, following the standards will become much more important.
Unfortunately, many document authors are unfamiliar with standards. Thus, they might not pay attention to the structure because they don't understand the philosophy of HTML; or, they might think of HTML as a physical page-description language, such as PostScript, rather than a logical, structure-oriented markup language. Browsers don't discourage this view, and might even encourage the physical view...