Tải bản đầy đủ (.pdf) (689 trang)

html and web design

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (17.12 MB, 689 trang )























































Team-Fly
®

HTML & Web
Design
Tips & Techniques
Kris Jamsa
Konrad King

Andy Anderson
McGraw-Hill/Osborne
New York Chicago San Francisco
Lisbon London Madrid Mexico City Milan
New Delhi San Juan Seoul Singapore Sydney Toronto
Copyright © 2002 by The McGraw-HIll Companies, Inc. All rights reserved. Manufactured in the United States of
America. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be
reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior
written permission of the publisher.
0-07-222825-3
The material in this eBook also appears in the print version of this title: 0-07-219394-8
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occur-
rence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark
owner, with no intention of infringement of the trademark. Where such designations appear in this book, they
have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for
use in corporate training programs. For more information, please contact George Hoare, Special Sales, at
or (212) 904-4069.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all
rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act
of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse
engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish
or sublicense the work or any part of it without McGraw-Hill’s prior consent. You may use the work for your
own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work
may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED “AS IS”. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES
OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE
OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED
THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WAR-

RANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not
warrant or guarantee that the functions contained in the work will meet your requirements or that its operation
will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for
any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom.
McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no cir-
cumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, conse-
quential or similar damages that result from the use of or inability to use the work, even if any of them has been
advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatso-
ever whether such claim or cause arises in contract, tort or otherwise.
DOI: 10.1036/0072228253
To Bonnie,
You are, and always will be, the most important part of my life.
–Andy
To my wife Karen,
Thanks for enduring the late hours, solitary meals, missed vacations,
and especially for listening to my moans and groans about the writing
“process.” Your knowing smiles and not so gentle (but needed)
“Just Do It!” inspired me to see the project through from concept
to completion.
–Konrad
To Stephanie,
Although you have grown up to become a very special woman,
you will always be our little girl.
–Dad
About the Authors
Konrad King is an author and computer systems consultant for a wide range of clients. A former
Air Force officer, Konrad has worked with mainframes as well as PCs and PC-based networks. He
has written and worked with award-winning authors on several books on SQL database design and
implementation, Web design, and Microsoft Office software, such as FrontPage and PowerPoint.

When not writing, Konrad designs, develops, and maintains Web sites; installs and maintains networks
and enterprise software; and develops custom software applications in Visual C++, Visual Basic,
DataFlex, and various SQL database platforms. Having worked in the computer field since 1984,
Konrad is able to draw from a vast pool of knowledge about what works in the “real world” and
what does not.
Andy Anderson is a graphics artist and designer and has worked with Photoshop, Illustrator,
and most graphics arts programs for the Web since their release. An author and university professor,
Andy is also a sought-after lecturer in the U.S., Canada, and Europe. The remainder of his time is
spent developing curriculum and resource materials for various corporations and seminar companies.
His clients include designers and trainers from the U.S. government, Boeing, Disneyland, and other
Fortune 500 companies.
Kris Jamsa is the author of more than 90 computer books, with cumulative sales of several
million copies. Kris holds a bachelor of science degree in computer science from the United States
Air Force Academy, a masters degree in computer science from the University of Nevada, Las Vegas,
a Ph.D. in computer science with an emphasis in operating systems from Arizona State University,
and a masters of business administration from San Diego State University. In 1992, he and his wife,
Debbie, founded Jamsa Press, a computer- book publishing company. After expanding the company’s
presence to 70 countries and 28 languages, they sold Jamsa Press to a larger publishing house. Today,
Kris is the founder of Jamsa Media Group, which produces high-quality computer books. He is also
very active in analyzing emerging technologies. Kris lives on a ranch in Houston, Texas, with his wife
Debbie, their three dogs, and six horses. When he is not in front of his PC, Kris is normally riding
and jumping his horse Robin Hood.
Contents at a Glance
Chapter 1 HTML Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Chapter 2 HTML Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Chapter 3 HTML Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Chapter 4 Cascading Style Sheets (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Chapter 5 XHTML and Emerging Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Chapter 6 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Chapter 7 Animation, Sound, and Video . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

Chapter 8 JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Chapter 9 Java Applets and ActiveX Objects . . . . . . . . . . . . . . . . . . . . . . . . . 418
Chapter 10 PHP4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Chapter 11 Active Server Pages (ASP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Chapter 12 Security and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
v
For more information about this title, click here.
Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
This page intentionally left blank.
Contents
Acknowledgments, xv
Introduction, xv
Chapter 1 HTML Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Downloading and Installing the Personal Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Managing the Personal Web Server and Publishing Your Web Pages . . . . . . . . . . . . . . . . . . . . . . 18
Describing Web Page Contents with a Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Identifying Web Documents Using the Document Type Definition . . . . . . . . . . . . . . . . . . . . . . . 23
Inserting Comments into a Web Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Specifying the Typeface for Web Page Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Controlling the Flow of Text with Paragraph and Line Break Tags . . . . . . . . . . . . . . . . . . . . . . . 27
Changing the Size of Text Using Heading Level Tags and the Font Tag
size
Attribute . . . . . . . . . . . . . . 32
Changing the Color of Text in an HTML Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Adding Graphics to a Web Page Using a Basic <img> Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Changing the Alignment of Text and Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Adding a Hypertext Link to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Enhancing Individual Letters and Words Using Character Formatting Tags . . . . . . . . . . . . . . . . . . . 41
Using Symbols and Special Characters in an HTML Document . . . . . . . . . . . . . . . . . . . . . . . . .42

Using Horizontal Rules to Organize Web Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Using Blockquote Tags to Control Left and Right Text Margins . . . . . . . . . . . . . . . . . . . . . . . . . 47
Creating Ordered and Unordered Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Creating Nested Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Creating Definition Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Using Preformatted Text Tags to Control the Display of Web Content . . . . . . . . . . . . . . . . . . . . . 54
Displaying a Navigation Menu Within a Web Page Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Displaying Multiple Web Pages Onscreen at the Same Time . . . . . . . . . . . . . . . . . . . . . . . . . . 57
vii
For more information about this title, click here.
Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
Chapter 2 HTML Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Creating a Table with Cells that Span Multiple Columns or Multiple Rows . . . . . . . . . . . . . . . . . . . .72
Working with Table and Cell Border Widths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Working with Table and Cell Border Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Working with Background Images and Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Determining a Color Attribute’s Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Working with Cell Padding and Cell Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Setting Table Dimensions Using Relative or Absolute Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Setting Cell Dimensions Using Relative or Absolute Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Aligning Cell Content Horizontally and Vertically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Aligning a Table on a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Controlling the Width and Height of a Cell by Inserting a Transparent GIF . . . . . . . . . . . . . . . . . . .89
Wrapping Text Around an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Displaying a Gallery of Thumbnails Within a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Creating Bullets and Lists with Tables and Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Creating a Navigation Sidebar Using a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Adding Images and Links to Table Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Nesting Tables to Control Borders on a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Approximating an Image Map by Placing Pieces of an Image Within a Table . . . . . . . . . . . . . . . . . . 100

Slicing a Graphic Image into Table Cells to Create a Quick-Loading Web Graphic . . . . . . . . . . . . . . . . 102
Reducing the Amount of Time a Web Browser Spends Drawing a Table . . . . . . . . . . . . . . . . . . . . . 103
Simulating Web Page Frames Using a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Focusing the Viewer’s Attention with Cell Background Colors . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Aligning Web Page Content Visually with Visible Table Borders . . . . . . . . . . . . . . . . . . . . . . . . . 108
Controlling Gutter Size and Margin Width of Text on a Web Page . . . . . . . . . . . . . . . . . . . . . . . 110
Chapter 3 HTML Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Creating a Single-Line Input Field on a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Creating a Multiline Input Field on a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Validating Text Element Data Prior to Submitting Form Results . . . . . . . . . . . . . . . . . . . . . . . . 122
Placing Check Boxes on a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Placing Radio Buttons on a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Validating Radio Button Group Selections Prior to Submitting Form Results . . . . . . . . . . . . . . . . . . . 128
Placing a Drop-Down List (Selection Menu) on a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Verifying the Visitor Has Made a Selection List Choice Prior to Submitting Form Results . . . . . . . . . . . . . 132
Changing the Items Available on a Selection List Based on Visitor Supplied Information . . . . . . . . . . . . 134
Sending All Selection List Values to the Web Server Through a Hidden Field . . . . . . . . . . . . . . . . . . 136
Adding a Reset Button to a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Preventing a Visitor from Clearing Form Elements Accidentally . . . . . . . . . . . . . . . . . . . . . . . . 139
Adding a Submit Button to a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
viii HTML & Web Design Tips & Techniques
Replacing the Standard Submit and Reset Buttons on a Form with Other Graphics Images . . . . . . . . . . . 141
Sending Form Results by E-Mail Without a CGI Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Controlling the Layout of Form Elements and Text with HTML Tables . . . . . . . . . . . . . . . . . . . . . . 145
Creating a Shortcut Key for Form Navigation with a <label> Tag . . . . . . . . . . . . . . . . . . . . . . . 148
Instructing the Web Browser to Execute a Form Validation Function with the
onClick
Attribute . . . . . . . . . 149
Passing Values to the Web Server Through Hidden Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Hiding Visitor Input from View Within a Password Element . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Adding a Generic Button Object to a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Enabling and Disabling Form Elements on-the-Fly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Chapter 4 Cascading Style Sheets (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Applying Multiple CSS Rules to a Single Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Selecting a Typeface with the
font-family
Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Specifying the Size of Text with the
font-size
Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Creating Overlapping Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Aligning Web Page Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Controlling Margins and Line Height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Displaying Text Within Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Working with Borders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Indenting Paragraphs and Controlling Letter, Word, and Line Spacing . . . . . . . . . . . . . . . . . . . . . 188
Offsetting Text with Initial Caps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Customizing the Appearance of Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Creating a Drop-Shadow Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Applying a Border Graphic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Positioning Background Images and Watermarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Floating Images and Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Customizing the Appearance of Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Creating Text and Image Effects with Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Aligning Labels with Form Elements and Adding Color to Forms . . . . . . . . . . . . . . . . . . . . . . . . 206
Displaying a Gallery of Thumbnails with Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Controlling the Cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Layering Web Page Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Sending Your Style Sheet Through a Validator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Chapter 5 XHTML and Emerging Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

Converting HTML to XHTML Using HTML Tidy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Selecting the Correct DOCTYPE for Your Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Validating Your Web Page with an XHTML Validator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Setting the Text Size on an XHTML Web Page with Keywords . . . . . . . . . . . . . . . . . . . . . . . . . 242
Grouping an XHTML Form’s Selection List Items with the <optgroup> Tag . . . . . . . . . . . . . . . . . . . 245
Adding Color to XHTML Tables with Cascading Style Sheet Rules . . . . . . . . . . . . . . . . . . . . . . . . 247
Contents ix
Embedding Fonts Within an XHTML Web Page with CSS Rules . . . . . . . . . . . . . . . . . . . . . . . . . 249
Inserting an XHTML Page Within Another with an Inline Frame . . . . . . . . . . . . . . . . . . . . . . . . 251
Updating Multiple XHTML Page Inline Frames at Once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Changing XHTML Page Appearance Based on Media Type . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Controlling the Way the Web Browser Prints an XHTML Web Page . . . . . . . . . . . . . . . . . . . . . . . 261
Chapter 6 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Working with Cross-Platform Issues When Creating Graphics Images for the Web . . . . . . . . . . . . . . . 274
Specifying Image Dimensions Within an Image Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Working with the
alt
Attribute and Text-Only Viewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Creating a Tool Tip by Inserting a
title
Attribute in an Image Tag . . . . . . . . . . . . . . . . . . . . . . . 281
Compressing Photographs into a JPEG File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Saving Clip Art and Text to a GIF-Formatted File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Making Images Appear to Load Faster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Working with the PNG-8 and PNG-24 File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Converting Graphics into Web Images with Image-Editing Programs . . . . . . . . . . . . . . . . . . . . . . 291
Creating Web-Friendly Graphics Images on Your Scanner . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Creating Colorful Horizontal Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Retrieving a Fast-Loading “Teaser” Image with the
lowsrc

Attribute . . . . . . . . . . . . . . . . . . . . . . 296
Ensuring Accurate Color Presentation with the Web-Safe Color Palette . . . . . . . . . . . . . . . . . . . . . 298
Creating Graphical Hyperlink Anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Creating Tiled Backgrounds from Graphics Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Creating Transparency in a GIF Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Retrieving Full-Size Images after Clicking on Thumbnails . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Preloading and Caching Images Behind the Scenes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Expanding the Web-Safe Color Palette with Dithering Techniques . . . . . . . . . . . . . . . . . . . . . . . 311
Smoothing the Edges of Text Converted into a Graphic Through Anti-Aliasing . . . . . . . . . . . . . . . . . 313
Chapter 7 Animation, Sound, and Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Creating a GIF Animation from Scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Controlling GIF Animation Through Internal Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Creating a Banner Ad Using GIF Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Creating Smooth Transitions Between GIF Animation Frames Using Tweening . . . . . . . . . . . . . . . . . 341
Incorporating a Completed Flash Splash Screen into a Web Site . . . . . . . . . . . . . . . . . . . . . . . . 342
Creating a Flash Movie from Scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Building Text-Based Animations Using FlaX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Broadcasting Streaming Audio and Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Creating Your Own Streaming Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Creating a Page that Features a Web Cam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Integrating Video and Audio into a Web Site Using SMIL (Smile) . . . . . . . . . . . . . . . . . . . . . . . . 354
Chapter 8 JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Handling Older Browsers that Do Not Support Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Storing Multiple Values in One Variable by Using JavaScript Arrays . . . . . . . . . . . . . . . . . . . . . . 371
x HTML & Web Design Tips & Techniques
TEAMFLY























































Team-Fly
®

Letting a Script Make Decisions and Process Accordingly . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Making Decisions Based on Two or More Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Executing Code When a Condition Is Not True . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Repeating Statements a Specific Number of Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Repeating Statements While a Condition Is True . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Responding to JavaScript Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Executing JavaScript Statements Within the Body of a Web Page . . . . . . . . . . . . . . . . . . . . . . . 380
Calling a User-Defined JavaScript Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

Calling JavaScript Functions Within an Event Handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Looking Closer at JavaScript Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Creating an Interactive Navigation Bar with a Mouseover Effect . . . . . . . . . . . . . . . . . . . . . . . . 388
Taking Advantage of the Scripting Object Model Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Referring to Web Page Objects by Name Instead of Position Number . . . . . . . . . . . . . . . . . . . . . 392
Leveraging the Contents of the Document Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Taking Advantage of the JavaScript Images Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Exploiting the JavaScript Links Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Changing Web Page Colors Using JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Storing a Cookie on the Visitor’s Hard Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Formatting Cookie Data Using JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Retrieving a Cookie Value from the Cookie File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Removing a Cookie from the Cookie File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Saving Time and Programming by Using Prewritten (External) Scripts . . . . . . . . . . . . . . . . . . . . . 409
Creating an Animation Using the
onLoad
Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Displaying Self-Changing Banners Using JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Pointing Hyperlinks to New Files On-the-Fly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Pre-caching Pictures to Reduce Image Display Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Creating a Scrolling Marquee Using JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Chapter 9 Java Applets and ActiveX Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Using an Applet to Create a Pop-Up Navigation Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Using an Applet to Animate a Text String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Using an Applet to Display and Print a Calendar for Any Year . . . . . . . . . . . . . . . . . . . . . . . . . 442
Using an Applet to Display a Passage at Random from a Text File . . . . . . . . . . . . . . . . . . . . . . . 443
Using an Applet to Create a Navigation Menu that Runs in Its Own Window . . . . . . . . . . . . . . . . . . 444
Using an Applet to Scroll the Contents of a File Vertically Within a Rectangular Box Onscreen . . . . . . . . . 448
Using an Applet to Animate an Image Along a Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Editing Java Source Code to Build a Custom Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

Using the Microsoft Chat ActiveX Control to Add Internet Chat to a Web Page . . . . . . . . . . . . . . . . . 457
Using Only ActiveX Objects with Internet Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Chapter 10 PHP4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Sending Data from an HTML Form to a PHP Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Using PHP to Parse and Extract Form Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Contents xi
Using PHP to Send an E-Mail Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Determining Whether a Visitor’s Web Browser Accepts Cookies . . . . . . . . . . . . . . . . . . . . . . . . 493
Using PHP and a Disk File to Set Up Username/Password Access to a Web Site . . . . . . . . . . . . . . . . . 496
Preventing Visitors from Linking Directly to Pages on Your Site . . . . . . . . . . . . . . . . . . . . . . . . 498
Using a PHP Session to Establish a Persistent Connection Between a Site Visitor and the Web Server . . . . . . 499
Creating a MySQL Database and Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
Displaying SQL Query Results in an HTML Table on a Web Page . . . . . . . . . . . . . . . . . . . . . . . . 504
Using PHP to Generate a Random Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Using PHP and MySQL to Set Up Username/Password Access to a Web Site . . . . . . . . . . . . . . . . . . 509
Preventing Visitors from Changing Variable Values with URL Arguments . . . . . . . . . . . . . . . . . . . . 511
Using PHP and MySQL to Track Where Visitors Go on Your Web Site . . . . . . . . . . . . . . . . . . . . . . 512
Determining the Visitor’s IP Address for Web Page Requests Sent Through a Proxy Server . . . . . . . . . . . 514
Preventing One Visitor from Assuming Another Visitor’s PHP Session Identity . . . . . . . . . . . . . . . . . 516
Using PHP Functions to Create Web Page Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Using PHP to Add File Upload Functionality to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Chapter 11 Active Server Pages (ASP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Controlling the Flow of Content from Web Server to Web Browser Through the HTML Output Stream . . . . . . 539
Preventing the Web Browser from Displaying Stale Active Server Pages . . . . . . . . . . . . . . . . . . . . 543
Redirecting the Web Browser to Another Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Maintaining Variable Values Between HTTP Requests with the Cookies Collection . . . . . . . . . . . . . . . . 547
Retrieving Form Results from the ASP Form Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
Retrieving Form Results from the ASP QueryString Collection . . . . . . . . . . . . . . . . . . . . . . . . . 553
Retrieving Information from the Server Variables Collection . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Connecting to a MySQL DBMS Through the MyODBC Driver . . . . . . . . . . . . . . . . . . . . . . . . . . 559

Setting Up Username/Password Access to a Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
Starting a Session and Working with Session Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Executing SQL Queries and Displaying Query Results Sets Within an HTML Table . . . . . . . . . . . . . . . . 568
Displaying Banner Ads with the Microsoft Banner Ad Rotator . . . . . . . . . . . . . . . . . . . . . . . . . 573
Tracking Microsoft Banner Ad Rotator Impressions and Click-Throughs . . . . . . . . . . . . . . . . . . . . . 576
Handling “Status: 404 Not Found” Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Chapter 12 Security and Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
Downloading and Installing a Public Key, Digital Signature, and Server ID . . . . . . . . . . . . . . . . . . . . . 600
Creating a Secure Web Page Under IIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Installing a Software-Based Firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Fine-Tuning a Firewall’s Port Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Reducing Your Site’s Exposure to Viruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Improving Performance and Security by Disabling Printer and File Sharing . . . . . . . . . . . . . . . . . . 610
Using Client Certificates to Restrict User Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612
Auditing System Events to Detect Intruders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
Exploiting the NTFS File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Disabling Remote Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
xii HTML & Web Design Tips & Techniques
Analyzing Your System’s Vulnerability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
Processing Credit Card Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Taking a Close Look at a Web Site’s Performance Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Creating a Web Farm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Monitoring Server Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Contents
xiii
This page intentionally left blank.
Acknowledgements
It’s nearly impossible to thank everyone who is involved in the process of taking an author’s
manuscript from concept to book form. Please take a moment and turn to page near the front of the

book that lists the Osborne team that brought this book together. This book’s quality content is
a direct result of their hard work and dedication.
We’d also like to thank this book’s technical editors Charles Hornberger and Wendy Willard for
their candor and selfless content contributions. Their insights greatly improved the book’s quality.
And, we’d like to thank Jim Schachterle for his support throughout this project and our project editor,
Janet Walden, for pulling together all the pieces.
Introduction
Analysts now estimate that across the Internet, over 100 million domain names are in use
(for Internet statistics, visit With fast DSL and cable-modem
connections available to the masses, and with companies offering low-cost Web hosting, tens of
millions of users are now creating personal Web sites. Further, with the estimates of online users
now exceeding 500 million (and with that number growing at a rate of 7 percent per month!), Web
developers must find ways to exploit new technologies to attract and capture the attention of users as
they “surf” the Web.
Throughout this book’s chapters, you will learn ways to put Web technologies immediately to
use on your Web pages. Each chapter presents ways you can quickly integrate a technology, such as
dynamic content, security, database access, as well as client-side and server-side processing. You will
first learn a technology’s fundamentals and the best ways to exploit the technology within your Web
pages. Then, you can take advantage of ready-to-use solutions you can simply cut-and-paste into your
Web pages. Finally, you will examine behind-the-scenes settings and techniques you can use to unlock
your Web site’s full potential.
If a fast, state-of-the-art, eye-catching Web site is your goal, this book will help you achieve it.
xv
Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
Who Should Read This Book
Across the Web, millions of users and professional Web developers work with Web pages daily. To
simplify their efforts, many Web developers rely on numerous Web development software programs
to help them with Web page design. Unfortunately, to exploit new Web technologies fully and to drive
Web site performance, developers must at some point roll up their sleeves and dig into HTML tags,
attributes, Cascading Style Sheet rules, JavaScript, Active Server Pages, PHP, and more.

Despite the vast number of sites that make up the World Wide Web, you would be hard pressed to
find a Web developer who would not be happier if his or her site were faster, more secure, or easier
to manage. Further, the users who visit sites not only want entertaining and current content, but also
want that content to download quickly. Most users assume that the sites that present themselves as
secure truly are secure. Regardless of the content you place on a Web site, users expect quality, speed,
and security.
This book examines hundreds of ways Web developers can improve their site’s performance,
security, content, and ease of management. You do not have to be an experienced programmer or
network administrator to perform the operations this book presents. Each Tip presents step-by-step
instructions you can easily perform, as well as solutions you can cut-and-paste into your Web pages.
Within the books chapters, you will learn:
• The HTML fundamentals you must know to create your first Web site, and the steps you must
perform to host that site on the Web
• Ways you can use HTML-based tables to organize information you present on a Web page, and
how to use tables to arrange text and graphics
• How you can use Cascading Style Sheets to gain full control of text formatting within a Web page
and to simplify future updates

How XHTML differs from HTML, new XHTML capabilities you can exploit within your
pages, as well as ways you can migrate your HTML pages to XHTML

Techniques you can use to better exploit graphics within your Web pages while reducing the
time users must wait for images to download

How to create dynamic Web page content using PHP and Active Server Pages

Behind-the-scenes operations you can perform to use HTTP and CGI settings to automate
solutions that exploit your user’s browser type, connection speed, and more

Ways you can secure your system from hackers and identify potential security holes in your

system that malicious users can exploit

How you can integrate e-commerce solutions and credit card processing into your Web site

And much more!
What You Need to Perform the Techniques We Present
This book presents a myriad of ways you can improve your Web site’s content, performance, security,
and ease of management. Within each chapter, you will find operations you can immediately perform
on your Web site.
xvi HTML & Web Design Tips & Techniques
To take advantage of the techniques we present, you do not need high-end software or other
graphics arts tools. You simply need to spend five to ten minutes performing the Tip’s step-by-step
instructions. The Tips will help you download from the Web (for free!) any tools that you will need.
For high-end Web developers and programmers, this book examines ways you can use scripts
to access many low-level operations. Each programming language this book presents is built into
browsers, servers, or is readily available for download from the Web. If you have not programmed
in these languages before, do not worry. Each chapter’s introduction will provide the foundation
you will need to exploit the language.
What This Book Covers
This book contains 12 chapters. Each chapter examines a specific Web technology, programming
language, or design technique. Within each chapter, you will find a thorough discussion of a technology
or language followed by Tips you can quickly perform to enhance your Web pages and the overall
design and performance of your Web site.
Chapter 1: HTML Basics To start, this chapter lays the foundation that designers new to Web
development need to exploit the techniques they will learn throughout the remainder of the book.
Designers will learn how to create HTML pages, how to display pages from files that reside on their
own PC, and then how to use a Web server to make their pages available to visitors across the Web.
Chapter 2: HTML Tables Within a Web page, tables provide designers with a powerful way to organize
large amounts of data for display onscreen. Many Web designers also use tables to gain better control
over the alignment of text and graphics that appear on a page. A designer might, for example, use tables

to flow text around an image. In addition, a Web page may present a table of thumbnail images from
which users can select the pictures that they want to download as a larger graphic.
Chapter 3: HTML Forms Across the Web, millions of sites use forms to interact with visitors. Forms
may ask the visitor to provide a wide range of information, such as a shipping address, personal data,
or credit card numbers for purchases. In addition, forms let visitors search for specific products, services,
or content available at the site, or perhaps elsewhere on the Web. Developers create forms using
HTML tags. After the user submits his or her information, the Web server runs a special program
(which developers call a script) that processes and likely stores the data. In this chapter, you will
learn how to create forms using HTML, how to validate the information a user enters using JavaScript,
and then how to process the data the user submits.
Chapter 4: Cascading Style Sheets (CSS) Within a Web page, developers use a wide range of HTML
tags to format text, graphics, and links. Using only HTML tags, such <b> for bolding, <i> for italics,
and so on, a Web developer can format Web page text as he or she desires. Unfortunately, if the
formatting must later be changed, the developer must change numerous tags. Cascading Style Sheets
make Web sites much easier to manage. Using Cascading Style Sheets, Web developers can assign
font, color, alignment, and many other attributes to the text that appears on a page. If the developer
must later change the page appearance, he or she can simply change the style definition and the
changes will immediately appear within the styled text. Further, for Web designers looking for
Introduction
xvii
high-end designs, Cascading Style Sheets allows precise positioning and even stacking text and
graphics to create countless effects.
Chapter 5: XHTML and Emerging Trends To ensure that your Web pages work and look the way you
want them to in the next generation of Web browsers, you must adhere to the World Wide Web
Consortium’s recommendations. When followed carefully, the “rules” within the XHTML standard
prevent you from creating Web pages with improper syntax, missing or proprietary tags, and invalid
attributes. By avoiding such bad code, you ensure your Web pages will look great and will work with
all standard Web browsers. Moreover, by guaranteeing the correctness of your Web page description
(by making it compliant with the XHTML standard), you allow browser manufacturers to omit code
designed to “guess” the intentions of malformed HTML. Browsers designed to run on non-PC devices

(such as cell phones, palm organizers, onboard computers within cars, and so on) must be small, because
these devices have limited memory capacities. This chapter shows you how to run an application
(HTML Tidy) which checks your Web page HTML, corrects any errors, and converts your HTML
to XHTML. You will also learn how to use online validation programs that check new Web pages
you create to ensure they comply with the XHTML standard. Then you will find Tips that show you
how to extend the capabilities of the markup language by adding new tags and attributes, as well as
Tips that let you detect the user’s browser type so your pages display quickly and correctly in browsers
running on non-PC devices.
Chapter 6: Graphics Across the Web, pages make extensive use of graphics. Unfortunately, many
sites that offer great visuals lose impatient visitors who are not willing to sit through long download
times. In this chapter you will learn techniques, such as caching and preloading, you can use, as well
as settings you can fine-tune to reduce image download times. You will also learn about the various
graphics file formats and when you should use each. Further, the chapter discusses color palettes and
ways you can ensure your content is “Web friendly.” Finally, graphics professionals will learn ways
to simplify the migration of images to the Web.
Chapter 7: Animation, Sound, and Video With high-speed cable-modem and DSL connections
becoming readily available, many Web sites use animations, background music, and video to capture
users’ attention. In this chapter, you will learn how to integrate a range of animations, from simple
animated graphics to high-end Flash animations. Further, you will learn how to play background
music as users view your pages and how to deliver streaming video content on demand. Finally,
you will learn how to broadcast audio (just as a Web-based radio station) from your Web site.
Chapter 8: JavaScript JavaScript is a programming language Web designers can use to automate
tasks within a Web page. Web developers place JavaScript statements within the HTML tags that
define a Web page. The JavaScript statements may, for example, validate the information the user
entered into a form. (The program or script may ensure each field has a value or that the values
appear correct and meaningful.) Or, JavaScript statements may perform specific processing as the
user performs operations on the page. For example, you might use JavaScript to display a pop-up
window that contains help text when a user clicks on a help link. Just as the user’s browser displays
the contents of an HTML page, the browser also executes the JavaScript statements. In this chapter,
xviii HTML & Web Design Tips & Techniques

you will first learn how to create simple JavaScript applications. Then, you will examine many
JavaScript solutions that you can cut-and-paste into your own Web pages.
Chapter 9: Java Applets and ActiveX Objects For years, programmers have used the Java programming
language to create applets that can run on a variety of platforms; meaning, the same Java applet can
run under Windows, Linux, and on a Mac. Java applets provide programmers a way to automate tasks
without introducing the risk of computer viruses to users who download the applets. Across the Web,
there are countless “generic” Java applets you may want to leverage within your own pages. In this
chapter, you will learn how to integrate Java applets into your HTML content. Further, the chapter
examines how to provide support for ActiveX objects for Windows-based sites. Unlike Java applets,
which do not provide security risks to the users that download them, ActiveX objects do not restrict
the operations the code can perform. Therefore, it is important that you only integrate ActiveX
objects you received from reputable developer sites that contain certificates of authentication.
Chapter 9 details the precautions you should take.
Chapter 10: PHP4 PHP is a programming language that developers use to create dynamic (changing)
Web page content on-the-fly. Using PHP, for example, you can customize your Web page content
based on the information a user provides within a form, or perhaps based on information you glean
from a cookie your site previously stored on the user’s disk. Across the Web, over 1,000,000 sites use
PHP to create dynamic Web pages. Before you can take advantage of PHP, you must download and
install a PHP processor on your system. This chapter will walk you through the installation process.
Then, you will learn how to create simple PHP-based applications. As discussed, PHP is a programming
language and the chapter’s introduction will lay the foundation you need to create, test, and debug
PHP programs. Then, the Tips section will present several PHP-based solutions you can put to immediate
use within your Web pages.
Chapter 11: Active Server Pages (ASP) Like PHP, Active Server Pages provide a way for Web
developers to create on-the-fly content. To create an Active Server Page (a dynamic Web page), you
can use a myriad of programming languages that include VBScript, JScript (the Microsoft version of
JavaScript), PerlScript, Python, Rexx, and more. This chapter lays the foundation from which you
can develop your own Active Server Page solutions. In addition, the chapter’s Tips provide solutions
to a range of common Web page needs, such as creating and processing cookies, processing forms,
interacting with databases, using usernames and passwords to control site access, displaying and

tracking banner ads, and more.
Chapter 12: Security and Performance This year, hackers and computer viruses will cost users and
businesses over 12 billion dollars! In this chapter, you will learn steps you should take immediately
to protect your site. If you are not currently using a firewall to protect your site (or simply your PC),
you will learn how to download, install, and configure a site. You will also learn how your choice
of file system (the software the operating system uses to store files and directories on your disk) can
affect your ability to protect files (using permissions and encryption). Further, the chapter presents
the steps you must perform to create secure transmissions (that exchange packets behind the scenes
using encryption), and how to perform credit card transactions. Finally, the chapter looks at ways
you can improve your site’s performance.
Introduction
xix
How to Read This Book
Although this book’s chapters build on the information presented in preceding chapters, we
structured the book so that you can turn to any Tip and find the information you need.
To help you quickly locate the information you need, at the start of each chapter, we have included
a list of the specific Tips that chapter presents. If you need more information on a topic, each chapter
provides introductory text that will give you a solid foundation.
As you scan through the book’s pages, watch for the Use It icon, which highlights
specific steps within each Tip that you can perform immediately to accomplish a task.
Using This Book’s Companion Web Site
Throughout this book’s chapters, we will present numerous HTML files, Active Server Pages,
JavaScript code, PHP solutions, and much more. In many cases, you can simply cut-and-paste the
solutions we present into your own Web pages. All of this book’s files are readily available from
the McGraw-Hill/Osborne Web site at .
xx HTML & Web Design Tips & Techniques
TEAMFLY























































Team-Fly
®

CHAPTER 1
HTML Basics
TIPS IN THIS CHAPTER

Downloading and Installing the Personal Web Server 16


Managing the Personal Web Server and Publishing Your Web Pages 18

Describing Web Page Contents with a Title 21

Identifying Web Documents Using the Document Type Definition 23
 Inserting Comments into a Web Document 24

Specifying the Typeface for Web Page Text 26

Controlling the Flow of Text with Paragraph and Line Break Tags 27

Changing the Size of Text Using Heading Level Tags and the Font Tag
size
Attribute 32

Changing the Color of Text in an HTML Document 33

Adding Graphics to a Web Page Using a Basic <img> Tag 35

Changing the Alignment of Text and Graphics 37

Adding a Hypertext Link to a Web Page 40

Enhancing Individual Letters and Words Using Character Formatting Tags 41

Using Symbols and Special Characters in an HTML Document 42

Using Horizontal Rules to Organize Web Content 44

Using Blockquote Tags to Control Left and Right Text Margins 47

Copyright 2002 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use.
1
H
ypertext Markup Language, or as it is more commonly known, HTML, is the computer
language at the heart of the World Wide Web. When you create a Web site, you use HTML
to put the text, pictures, animations, and perhaps video and sound onto the individual Web pages that
make up the site. In addition, HTML lets you insert hypertext links and interactive buttons that connect
your Web pages to other pages on your Web site and on other Web sites around the world. Web design
is a creative process, and HTML is simply one of the tools (the page description language) you use to
produce Web pages.
HTML is a text markup and not a programming language. In theory, a Web page you create using
HTML should be viewable by anyone with a computer, any Web browser, and access to the Internet.
In reality, the ability to view all the content on a Web page depends on the capabilities of your Web
browser. Web browsers are programs that interpret the HTML in Web page documents and display
text, pictures, and animations on the visitor’s computer screen. Either alone or with the help of other
installed programs, browsers also play back any video and sound files you use HTML to insert on
a Web page. The latest versions of the two most popular Web browsers, Microsoft’s Internet Explorer
and Netscape’s Netscape Navigator, can display just about anything you can use HTML to put onto a
Web page.
For visitors to access Web pages on your Web site, they must first connect to the Internet and start
a Web browser. After the Web server sends a Web page to the visitor’s computer, the Web browser
interprets the HTML in the Web page file and displays the file’s contents as text and graphics images
in the browser’s application window.
Web servers and Web browsers use the HyperText Transport Protocol (HTTP) to communicate.
Among other things, the HTTP protocol specifies both the way in which Web browsers and servers
send messages and the structure of the messages themselves. A thorough discussion of the various
HTTP message types and structures is beyond the scope of this book. However, to design and create
even complex Web sites, you need only a basic understanding of the HTTP request and response stream
(between Web browser and Web server) illustrated in Figure 1-1.


Creating Ordered and Unordered Lists 48

Creating Nested Lists 51

Creating Definition Listings 52

Using Preformatted Text Tags to Control the Display of Web Content 54

Displaying a Navigation Menu Within a Web Page Frame 56

Displaying Multiple Web Pages Onscreen at the Same Time 57
1. Each time you enter a Web address (such as ) into your browser’s
Address field and press
ENTER, the Web browser sends an HTTP request for a file over the
Internet to the Web server.
2. After it receives the HTTP request for a file, the Web server retrieves the requested file and
sends the Web page to the Web browser.
3. The Web browser analyzes the Web page file to determine if there are any inserted files (such
as graphics, animations, sounds, and so on) that the browser needs from the Web server.
4. The Web browser sends multiple HTTP requests (one for each file the browser needs) to the
Web server.
5. As the Web server receives the HTTP requests for files, the server finds each file and sends
the files (one file per HTTP request) to the Web browser.
6. The Web browser takes the original Web page files, follows the instructions given by the
HTML tags in the file to combine the Web page and the inserted file contents into a Web
document the browser displays onscreen.
Understanding the Roles of Web Browsers and Web Pages
To keep up with the changing market, and to make the Internet available to all, Microsoft and
Netscape have made versions of their Web browsers for all commercially available computer
2 HTML & Web Design Tips & Techniques

Figure 1-1 A Web server handling a request for Web content

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×