HTML
          
By
              
Example

by Todd Stauffer


C  O  N  T  E  N  T  S



Introduction



Part I  Internet, Web, and HTML Fundamentals


Chapter 1  What is HTML?

Chapter 2  The World Wide Web and Web Servers

Chapter 3  How Web Browsers Work

Chapter 4  HTML's Role on the Web

Chapter 5  What You Need for a Web Site

Part II  Creating Basic Pages with HTML 2.0

Chapter 6  Creating a Web Page and Entering Text

Chapter 7  Changing and Customizing HTML Text

Chapter 8  Displaying Text in Lists

Chapter 9  Adding Graphics to Your Web Pages

Chapter 10  Hypertext and Creating Links

Chapter 11  Using Links with Other HTML Tags

Part III  Interactive HTML

Chapter 12  Clickable Image Maps and Graphical Interfaces

Chapter 13  HTML Forms

Chapter 14  Form Design and Data Gathering with CGI Scripts

Part IV  Adding Tables to Your Documents

Chapter 15  Adding Tables to Your Documents

Chapter 16  Images, Multimedia Objects, and Background Graphics

Chapter 17  Client-Side Image Maps

Chapter 18  Other HTML 3.0 Proposals

Chapter 19  Netscape HTML

Chapter 20  Netscape Frames

Chapter 21  Internet Explorer Extensions

Part V  Internet Programming and Advanced Web Technologies

Chapter 22  Using Java and JavaScript

Chapter 23  JavaScript Objects and Functions

Chapter 24  Understanding VRML and Creating VRML Objects

Chapter 25  Creating VRML Worlds

Chapter 26  Adding Portable Documents to Web Sites

Part VI  HTML Editors and Tools

Chapter 27  Creating HTML Documents with Netscape Gold

Chapter 28  Using Microsoft Internet Assistant

Chapter 29  HTML with Adobe PageMill for Macintosh

Part VII  HTML Examples

Chapter 30  HTML Examples

Appendix  Answers to Review Questions

Credits


© 1996 by Que Corporation

All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced, in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que, 201 W. 103rd St., Indianapolis, IN 46290. You may reach Que's direct sales line by calling 1-800-428-5331.

ISBN: 0-7897-0812-4

HTML conversion by :
    M/s. LeafWriters (India) Pvt. Ltd.
    Website : http://leaf.stpn.soft.net
    e-mail : leafwriters@leaf.stpn.soft.net

This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book, including but not limitied to implied warranties for the book's quality, performance, merchantability, or fitness for any particular purpose. Neither Que Corporation nor its dealers or distributors shall be liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to be caused directly or indirectly by this book.

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

Screen reproductions in this book were created using Capture from Mainstay, Camarillo, CA.


President:Roland Elgey
PublisherJoseph B. Wikert
Publishing Manager Jim Minatel
Editorial Services Director Elizabeth Keaffaber
Managing Editor Sandy Doell


Acquisitions Manager Cheryl D. Willoughby Product Director Mark Cierzniak
Production Editor Maureen A. Schneeberger
EditorsGill Kent, Kathy Simpson, Patrick Kanouse, Elizabeth A. Bruns,
Product Marketing Manager Kim Margolius Assistant Product Marketing Manager Christy M. Miller
Strategic Marketing Manager Barry Pruett Technical Editors Jim Minatel, Tobin Anthony
Technical Support Specialist Nadeem Muhammed Acquisitions Coordinator Jane K. Brownlow
Software Relations Coordinator Patricia J. Brooks Editorial Assistant Andrea Duvall
Book Designer Kim ScottCover Designer Ruth Harvey
Production Team Marcia Brizendine, Jenny Earhart, Bryan Flores, Trey Frank, Amy Gornik, Daniel Harris, Damon Jordan, Bob LaRoche, Michelle Lee, Casey Price, Kaylene Riemen, Laura Robbins, Kelly Warner, Paul Wilson
IndexerBrad Herriman

Dedication

To Mom: In addition to everything else you've given me over the years, thanks for the time, support, help, concern, cash, and, perhaps most of all, your technical writing gene.

About the Author

Todd Stauffer has been writing nonstop about computers since his graduation from Texas A&M University, where he studied English, Management Information Systems, and entirely too much golf. Since that time, he has worked as an advertising writer, freelance magazine writer, and magazine editor-all in the computer industry.

Todd is currently the Internet-issues columnist for Peak Computing Magazine and host of the weekly Peak Computing Hour Radio Show in Colorado. He has written a number of other books published by Que including Using Your Mac, Using the Internet with Your Mac, Easy AOL, Special Edition Using Netscape, and Special Edition Using the Internet with Your Mac.

He does other, non-computer-related things, too-just in case you were concerned.

Acknowledgments

As is generally the case, this book was only brought to fruition by the dedication and hard word of a big chunk of the staff at Que, without whom this project would just be a bunch of random, poorly edited text characters in generic-looking Courier. Thanks especially to Cheryl Willoughby, Mark Cierzniak, Maureen Schneeberger, Jim Minatel, and all the copy editors who worked on this book.

I'd also like to thank the folks at Peak Computing Magazine for being so understanding about deadlines, helping me make the transition to Colorado living, and giving me enough money to keep buying Campbell's soup for the duration of writing this book. Editor-in-Chief Laura Austin-Eurich was especially helpful in talking me down out of trees, and I appreciate General Manager Dean Jacobus' willingness to let me sleep through his meetings.

Big thanks to Dad (Chris Stauffer) for buying me dinner and a game of golf every once in a while to keep me sane. (Not to mention helping me through the trauma of tax session.) And, finally, thanks to all my friends back in Texas for calling every once in a while, just to make sure I wasn't dead.

We'd Like to Hear from You!

As part of our continuing effort to produce books of the highest possible quality, Que would like to hear your comments. To stay competitive, we really want you, as a computer book reader and user, to let us know what you like or dislike most about this book or other Que products.

You can mail comments, ideas, or suggestions for improving future editions to the address below, or send us a fax at (317) 581-4663. For the online inclined, Macmillan Computer Publishing has a forum on CompuServe (type GO QUEBOOKS at any prompt) through which our staff and authors are available for questions and comments. The address of our Internet site is http://www.mcp.com (World Wide Web).

In addition to exploring our forum, please feel free to contact me personally to discuss your opinions of this book: I'm mcierzniak@que.mcp.com on the Internet, and 76245,476 on CompuServe.

Thanks in advance-your comments will help us to continue publishing the best books available on computer topics in today's market.

Mark Cierzniak
Product Director
Que Corporation
201 W. 103rd Street
Indianapolis, Indiana 46290
USA


Introduction

If you're ready to jump into the world of creating HTML pages, you've found the right book-regardless of your previous experience with programming or the World Wide Web. That's because HTML by Example uses a "hands-on" approach to creating Web pages that will make learning HTML a pleasure. Forget about tired reference manuals or overly technical treatises that make HTML actually seem difficult. It's not! If you've got a text editor in DOS, Windows, OS/2, Mac, or a UNIX variant, the only other tool you need is this book. Now you're ready to create your presence on the Web.

What's the by Example Advantage?

There are two major reasons why learning HTML is easier when it's by Example. First, HTML isn't a typical programming language-in fact, it isn't a programming language at all. It's a "mark-up" language that builds on very basic concepts that are all somewhat related to one another. Learning by example, then, allows you to start with the initial concepts and learn to build to make complex Web pages come to life easily.

Second, with the included CD-ROM, HTML by Example gives you a major headstart in Web creation. Why? Because if you see an example that's similar to what you want to create, just copy the example from the CD and alter it to suit your needs. It's possible to have a Web page created within minutes of finding a suitable example! Just copy and paste.

Who Should Use This Book?

Before you get to the point of actually creating HTML documents (Web pages), you'll go through a little refresher course on the Internet and the World Wide Web. So, even if you're not terribly familiar with the Web, I'll try to get you there before throwing any strange codes or address at you.

Essentially, all you need to use this book is a rudimentary grasp of the Internet and Web, and a desire to create your own presence. If you've just "heard" of the Web, or even if you've been surfing for a while and want to know more about Web page creation, you've found the right book.

Programmers and graphic artists will also find this book useful for making the transition to the Web-although I should make the point that Web design is not in any way as complicated or cerebral as programming. For the basics (and even for the best looking Web pages), no programming expertise is required. Later in this book, you'll learn how to make your pages "cutting-edge" with emerging tools like JavaScript. But even for that, programming is not a prerequisite.

Why Should I Learn HTML?

The World Wide Web is easily the fastest growing part of the Internet, and thousands of new sites are added daily. As business and commerce begin to embrace the Web more fully, HTML skills are a wonderful enhancement to any résumé.

Creatives like writers, designers, and artists should also be learning more about the Web. The commercial art and advertising worlds are already making this transition to the new medium, and you should be getting yourself ready for it as well. A solid understanding of HTML will take you a long way into the future of your craft.

By the same token, nearly any computer professional should have some notion of how HTML works and why the Web is based on it. But that doesn't mean it takes a scientist to create Web pages. Office workers, editors, public relations specialists, salespeople, real estate agents, financial advisors, and consultants of all flavors should all have a Web presence, and can benefit from doing it themselves.

And the Web is so diverse that it's impossible to categorize all the reasons to learn HTML page creation. Home office pages, small businesses online, family photo sessions, and even hobbyists are all hanging their shingle on the Web-and finding new contacts, comrades, and cohorts in the process. And perhaps the most important reason to learn about HTML is to find out that it simply isn't that difficult to master. This book will give you a wonderful reason not to pay $150 an hour for Web services.

What Tools Do I Need?

For the approach you're taking to Web creation, all you need is a text editing program like Windows 95 Notepad, WordPad, the Mac's SimpleText, and VI or Emacs on UNIX platforms. Any basic ASCII text editor will work fine.

There are a number of HTML editing programs that are beginning to appear, both in shareware and commercial versions, but you're not going to start with them. (Some of the more popular of these are discussed in the final chapters of this book.) The reasoning is simple-even the most advanced HTML editors require an understanding of HTML if you're going to create anything more than the most rudimentary of pages. It's still an industry in its infancy, and you're much better off if you know what you're doing.

Once you're through with this book (which shouldn't take long!) and you've got a solid grasp of HTML, feel free to try out some of the graphical HTML editing programs. They'll make creating basic pages much easier-although you still have to fire up your text editor to get some of the sophisticated design accomplished.

You'll also need a stand-alone (i.e., not part of an online service) Web browser program or two for viewing and critiquing your documents. If you don't have a Web browser program (like Netscape Navigator or Microsoft Internet Explorer), some popular versions are available on the included CD-ROM. You don't necessarily need an Internet connection for most of this book, since you'll be dealing with files that you create or copy from the CD-ROM.

How This Book Works

Each chapter starts by explaining a particular concept, giving examples in "snippets" of HTML markup as you go along. Once you've got that concept under your belt, you'll be ready to work with a full-blown example. You can either type in the example or copy it from the CD-some of the examples will also suggest that you modify the text to make it more suitable for you personally. When you're done, you can simply view the document in your Web browser, if appropriate.

The key to the organization of this book is simple: it builds. You'll start out very simply, by going over Web concepts and creating basic pages. From there, you'll learn the various "standards" of HTML and how to decide which one is right for you. Then, you'll work from that foundation to learn the latest in HTML and Web developments, including all of the current codes for Netscape, Internet Explorer, and HTML 3.0 level development. Finally, you'll end with a look at virtual reality on the Web and do a little programming in JavaScript.

You'll also notice that nearly every chapter includes review questions and exercises to help you reinforce what you've learned. If you gave up review questions in grammar school, that's fine. Just skip to the next chapter. If you'd like to make sure you've covered all the material, though, the "Summary" section will help you know for sure that you're ready to move on.

Overview of Chapters

This books is divided into logical parts and chapters to help you find the lessons that are most appropriate for your knowledge level. What follows is a description of each part of the book, including a look at each chapter.

Part I: Internet, Web, and HTML Fundamentals

Chapter 1, "What is HTML?," introduces you to the fundamentals of creating documents for the Web. Chapter 2, "The World Wide Web and Web Servers," discusses the different conventions used to addressing computers, servers, and services on the Internet. Chapter 3, "How Web Browsers Work," takes a look at how the typical Web browser program reads HTML documents that you create, and what you need to consider to create better pages.
Chapter 4, "HTML's Role on the Web," is concerned with the different standards for HTML, and it helps you decide what's best to use on your pages. Chapter 5, "What You Need for a Web Site," rounds out this introduction with a discussion of the arrangements you need to make to make your Web pages visible to the online world.

Part II: Creating Basic Pages with HTML 2.0

This section discusses creating the basic Web page with HTML 2.0 standard commands. Chapter 6, "Creating a Web Page and Entering Text," and Chapter 7, "Changing and Customizing HTML Text," show you how to get started with your Web document and emphasize regular text. In Chapter 8, "Displaying Text in Lists," you learn the various types of HTML list that can be used to organize text in a more readable way.
Chapter 9, "Adding Graphics to Your Web Pages," is your first look at adding basic images to enhance your Web page presentation. Chapter 10, "Hypertext and Creating Links," and Chapter 11, "Using Links with Other HTML Tags," show you how to get serious about your Web pages by adding clickable hypertext links.

Part III: Interactive HTML

Here's where things really start to get fun. Still using only HTML 2.0 elements (although these are not all supported by every Web browser anymore), we take three chapters to discuss making your Web site truly interactive. In Chapter 12, "Clickable Image Maps and Graphical Interfaces," we discuss creating images that move your user around the Web site. Chapter 13, "HTML Forms," and Chapter 14, "Form Design and Data Gathering with CGI Scripts," shows you how to gather information from your users, whether it's for statistical data, online ordering, or just for fun.

Part IV: Page Layout and Formatting

These chapters move you out of the HTML 2.0 standard and into some of the more recent additions to HTML. Coverage includes HTML 3.0 level standards and HTML elements added by the popular browsers Netscape Navigator and Microsoft Internet Explorer.
In the HTML 3.0 discussion, you get Chapter 15, "Adding Tables to Your Documents," Chapter 16, "Images, Multimedia Objects, and Background Graphics," and the exciting new standard for adding clickable images to any Web page in Chapter 17, "Client-Side Image Maps." Chapter 18, "Other HTML 3.0 Proposals," is a catch-all chapter for some of the HTML 3.0 commands you may be seeing in the near future.
Next up are the Netscape-specific commands. Although some of these are slowly being adapted by other browsers, at the time of this writing they aren't "official" standards, so we set them off on their own. In Chapter 19, "Netscape HTML," you learn about the appearance-oriented additions that make Netscape pages standout from HTML 2.0. Chapter 20, "Netscape Frames," shows you exactly how to use the exciting new frames interface that's sweeping the Web.
Chapter 21, "Internet Explorer Extensions," takes a quick look at some of the additions offered by Microsoft's entry in the browser wars. These commands are specific to Microsoft and have yet to be incorporated into an official standard.

Part V: Internet Programming and Advanced Web Technologies

In this section of the book, you delve into some of the most cutting-edge and exciting technologies to be introduced to the World Wide Web. Chapter 22, "Using Java and JavaScript," and Chapter 23, "JavaScript Objects and Functions," are an easy-to-follow look at the world of JavaScript, showing you how to do your own programming in one of the most advanced scripting languages available for Web developers.
Chapter 24, "Understanding VRML and Creating VRML Objects," and Chapter 25, "Creating VRML Worlds," show you how to use a standard text editor to create 3D virtual reality worlds for use on your Web pages. Chapter 26, "Adding Portable Documents to Web Sites," introduces you to the concept of portable documents and offers advice for creating your own "nearly-free" portable documents for distributing on the Web.

Part VI: HTML Editors and Tools

In this section, we discuss some of the more popular applications for creating Web pages quickly and easily. As Web development becomes more popular, the tools become more advanced. Chapter 27, "Creating HTML Documents with Netscape Gold," introduces you to the all-in-one solution to Web browsing and editing from Netscape Corp. Chapter 28, "Using Microsoft Internet Assistant," discusses Microsoft's powerful (and free) HTML add-on for Microsoft Word. Chapter 29, "HTML with Adobe PageMill for Macintosh," takes a look at the tool that many feel may soon change the way you look at HTML and the Web.

Part VII: HTML Examples

This last part of the book has only one chapter, Chapter 30, "HTML Examples," but it's a long one. Here, you'll take a look at two completely different reasons to create a Web site: personal and business. In each, you'll review some of the basic and advanced Web concepts you've encountered throughout the book. The best part is that all of these pages are on the included CD-ROM. If you find a page that does something you want to add to your Web site, then just copy it from the CD and alter it to suit your needs!

Conventions Used in this Book

This books uses the following typeface conventions:

TypefaceMeaning
ItalicVariables in "pseudocode" examples and HTML terms used the first time
BoldText you type in, as well as URLs and addresses of Internet sites, newsgroups, mailing lists, and Web sites
Computer type Commands, filenames, and HTML tags

Note
Notes provide additional information related to a particular topic.

Tip
Tips provide quick and helpful information to assist you along the way.

Icons Used in this Book

Pseudocode is a special way of explaining a section of code by using placeholders, set in italic. In this book, pseudocode usually precedes a code example and is indicated by this icon.

The Other Advantage

In my experience writing computer-oriented books, I've found that one advantage I can offer might be more valuable to many readers than nearly any other. That advantage is my personal e-mail address. I will take any question, concern, praise, or complaint you have about this book, and its examples, errors, or anything else that comes up. Write me at tstauffer@aol.com via the Internet or TStauffer on the America Online service.

It is very important to me that you are satisfied with everything you come across in this book. If you get through a chapter and review questions and still have trouble with a concept, do not hesitate to send me an e-mail and ask about it. I'll return your e-mail as quickly as possible. I don't want you wasting time on a concept that I've explained poorly or on an error (however impossible) that I've made. So write before you lose too much time hitting yourself over the head.

Also, I'll continue to post updates, errata, and anything else that might be of interest on my personal Web site, currently located at http://members.aol.com/tstauffer/. That address may change in the future, but I'll do my best to leave a link to the new address, if and when it changes. For now, at least, that page on the Web will be a great place to stop by and check on HTML by Example developments.