Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, Swift, BASIC, and whatever else I happen to feel like hacking at.

HTML & XHTML: The Definitive Guide

Jerry Stratton, September 13, 2001

When you write in HTML, you use ‘tags’ to surround your content and information about your content, in order to display them in some way to web browsers. A web browser is anything that reads your HTML files: it might be a graphical web browser such as Netscape or iCab, or it might be a voice reader used by the blind, or a search engine’s spider, or a web-enabled PDA. If you use intelligent choices in your HTML design, you’ll be able to handle all of these, and even browsers that haven’t been born yet.

Few, if any, of the inexpensive or free web page editors can produce this kind of widely-accessible HTML code. Front Page, perhaps the most widely-used of the free editors, has a reputation for producing HTML that can’t be read by anything other than Internet Explorer on the platform the code was produced on, and sometimes not even that!

If you want to produce web pages that increase your readership, you either have to purchase a more professional web page editor, or learn to create the HTML yourself, or, more likely, both. Fortunately, while sometimes tedious, HTML is not hard to understand. As long as you understand that you are surrounding information with tags that describe the information, everything else can be looked up in references such as this one.

All of your content has to be surrounded by something. You designate that your web page contains web page content by surrounding it with <HTML> and </HTML>. The ‘HTML’ tag ‘describes’ an HTML page. HTML tags are a keyword surrounded by a less than symbol (<) and a greater than symbol (>). The ending HTML tag also has a ‘/’ before the keyword.

There are two sections to your web document: the header, which contains information about the document, and the body, which contains the information you wish to convey—usually, the text that people will read. The header is surrounded by the HEAD tag, and the body by the BODY tag. You set the title of your document (in the header) with the TITLE tag. You set your main headline with the H1 tag and your paragraphs with the P tag. For example:

[toggle code]

  • <html>
    • <head>
      • <title>HTML Guide Review</title>
    • </head>
    • <body>
      • <h1>FireBlade Coffeehouse HTML Guide Review</h1>
      • <p>I’ve never found an HTML book that I’ve considered great. This one is probably the best. It covers just about everything in HTML, as well as a little bit of Cascading Style Sheets.</p>
    • </body>
  • </html>

This is a full, if extremely simple, HTML page. Notice that every beginning tag has an ending. In HTML this is not always the case, though it usually is. In XHTML this will be always the case.

“HTML & XHTML: The Definitive Guide” includes a “Quick Start” chapter that goes into this in more detail, as well as describing content-based text styles that can emphasize words, and how to make hyperlinks.

The book has a small chapter on using Cascading Style Sheets as well. Style sheets allow you to describe the physical layout of your web page. While HTML is designed to describe what the content ‘means’ so that the browser can determine the best way to display it, style sheets let you tell specific kinds of browsers how they ought to display your page. Obviously, you cannot create style sheets for all browser types; those browsers you don’t provide a style sheet for will use the HTML to determine physical presentation.

For example, the EM tag emphasizes text. By default, visual browsers will often italicize emphasized text, and voice readers will aurally emphasize the text. With a style sheet, you can specify that all emphasized text be displayed underlined in blue, or in slightly larger font size, or using a different font. Clearly, a black and white PDA or a voice reader will ignore the instructions to display emphasized text in blue, but they will still be able to emphasize the text on their own. Style sheets thus very nicely complement HTML. This book does not go into detail on style sheets; to do so would have made the book prohibitively large. O’Reilly has a separate book on style sheets that you’ll find invaluable if you need to control the physical layout of your pages. Most of the time, and especially as you start out, you don’t need to. Specify the content’s meaning, and let the browser determine the best way to display it to the reader.

This guide is comprehensive. It covers standard HTML as well as the special tags created by Netscape and Microsoft. It goes into detail on using frames, forms, and tables. It even covers the most basic Javascript (a mouse-sensitive image is one example) but if you wish to use Javascript you’ll want a Javascript guide in addition to this book.

There are problems. In some places it is surprisingly non-comprehensive; in others, it makes strange statements. For example:

  1. In the section on ‘meta’ tags, the ‘keywords’ tag is mentioned, but the ‘description’ tag is not, and there is no list of commonly-used meta tags. Both keywords and descriptions are important tags for search engines.
  2. In the section on the deprecated ‘compact’ tag for definition lists, it states that “few browsers, if any, honor this attribute”. Well, Netscape has since at least version 2, and up to 4.05. (Deprecated means it will disappear from the HTML tagset eventually. Browsers no longer have to support it; in this case, it has been replaced by a style sheet property.)
  3. The chapter headings are on the inside of the page instead of the outside! You can’t flip through this book to quickly find a topic. When you’re not sure exactly what section you need, flipping quickly through can be an easy way of getting an idea.

On the other hand, just because this book sucks (I’m exaggerating), doesn’t mean you shouldn’t buy it. It sucks less than any other HTML book I’ve seen. It is the best I’ve seen, and if you write HTML you do need a reference. I recommend this one. If you don’t know HTML, and you design web pages, you should learn it, because what you learn will inform your choices for web design. Start from one of the many on-line HTML tutorials, and, if you like what you see, get a good reference such as this one.

  1. <- Perl Cookbook
  2. Nutshell Webmaster ->