HTML 4.01 Weekend Crash Course 0764547461, 9780764547461

The Weekend Crash Course series consists of 30 sessions over a period of three days. Each session is designed to take 30

359 92 5MB

English Pages 426 Year 2000

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Cover......Page 1
Preface......Page 9
Contents......Page 18
Session 01......Page 29
Session 02......Page 41
Session 03......Page 55
Session 04......Page 67
Session 05......Page 76
Session 06......Page 90
Session 07......Page 106
Session 08......Page 120
Session 09......Page 130
Session 10......Page 142
Session 11......Page 155
Session 12......Page 167
Session 13......Page 183
Session 14......Page 197
Session 15......Page 213
Session 16......Page 225
Session 17......Page 237
Session 18......Page 247
Session 19......Page 261
Session 20......Page 279
Session 21......Page 296
Session 22......Page 306
Session 23......Page 316
Session 24......Page 328
Session 25......Page 340
Session 26......Page 356
Session 27......Page 367
Session 28......Page 381
Session 29......Page 393
Session 30......Page 407
Appendix A......Page 415
Appendix B......Page 423
Recommend Papers

HTML 4.01 Weekend Crash Course
 0764547461, 9780764547461

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

HTML 4 .0 1 Weekend Crash Course™

HTML 4.01 Weekend Crash Course™ Greg Perry

IDG Bo o ks Wo rldwide, Inc. An Inte rnatio nal Data Gro up Co mpany Fo ste r City, CA • Chicago , IL • Indianapo lis, IN • Ne w Yo rk, NY

HTML 4 .0 1 We e ke nd Crash Course ™ Published by

IDG Books Worldwide, Inc. An Internatio nal Data Gro up Co mpany 919 E. Hillsdale Blvd., Suite 400 Fo ster City, CA 94404 www.idgbooks.com ( IDG Bo o ks Wo rldwide Web site) Co pyright © 2000 IDG Bo o ks Wo rldwide, Inc. All rights reserved. No part of this bo o k, including interio r design, cover design, and ico ns, may be repro duced o r transmitted in any fo rm, by any means ( electro nic, pho to co pying, reco rding, o r o therwise) witho ut the prio r written permissio n of the publisher. ISBN: 0- 7645- 4746- 1 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/ QZ/ QY/ QQ/ FC Distributed in the United States by IDG Bo o ks Wo rldwide, Inc. Distributed by CDG Bo o ks Canada Inc. fo r Canada; by Transwo rld Publishers Limited in the United Kingdo m; by IDG No rge Bo o ks fo r No rway; by IDG Sweden Bo o ks fo r Sweden; by IDG Bo o ks Australia Publishing Co rpo ratio n Pty. Ltd. fo r Australia and New Zealand; by TransQuest Publishers Pte Ltd. fo r Singapo re, Malaysia, Thailand, Indo nesia, and Ho ng Ko ng; by Go to p Info rmatio n Inc. fo r Taiwan; by ICG Muse, Inc. fo r Japan; by Intersoft fo r So uth Africa; by Eyro lles fo r France; by Internatio nal Tho mso n Publishing fo r Germany, Austria, and Switzerland; by Distribuido ra Cuspide fo r Argentina; by LR Internatio nal fo r Brazil; by Galileo Libro s fo r Chile; by Edicio nes ZETA S.C.R. Ltda. fo r Peru; by WS Co mputer Publishing Co rpo ratio n, Inc., fo r the Philippines; by Co ntempo ranea de Edicio nes fo r Venezuela; by Express Co mputer Distributo rs fo r the Caribbean and West Indies; by Micro nesia Media Distributo r, Inc. fo r Micro nesia; by Chips Co mputado ras S.A. de C.V. fo r Mexico ; by Edito rial No rma de Panama S.A. fo r Panama; by American Bo o ksho ps fo r Finland.

Fo r general info rmatio n o n IDG Bo o ks Wo rldwide’s bo o ks in the U.S., please call o ur Co nsumer Custo mer Service department at 800- 762- 2974. Fo r reseller info rmatio n, including disco unts and premium sales, please call o ur Reseller Custo mer Service department at 800- 434- 3422. Fo r info rmatio n o n where to purchase IDG Bo o ks Wo rldwide’s bo o ks o utside the U.S., please co ntact o ur Internatio nal Sales department at 317- 596- 5530 o r fax 317- 572- 4002. Fo r co nsumer info rmatio n o n fo reign language translatio ns, please co ntact o ur Custo mer Service department at 800- 434- 3422, fax 317- 572- 4002, o r e- mail rights@ idgbo o ks.co m. Fo r info rmatio n o n licensing fo reign o r do mestic rights, please pho ne +1- 650- 653- 7098. Fo r sales inquiries and special prices fo r bulk quantities, please co ntact o ur Order Services department at 800- 434- 3422 o r write to the address above. Fo r info rmatio n o n using IDG Bo o ks Wo rldwide’s bo o ks in the classro o m o r fo r o rdering examinatio n co pies, please co ntact o ur Educatio nal Sales department at 800- 434- 2086 o r fax 317- 572- 4005. Fo r press review co pies, autho r interviews, o r o ther publicity info rmatio n, please co ntact o ur Public Relatio ns department at 650- 653- 7000 o r fax 650- 653- 7500. Fo r autho rizatio n to pho to co py items fo r co rpo rate, perso nal, o r educatio nal use, please co ntact Co pyright Clearance Center, 222 Ro sewo o d Drive, Danvers, MA 01923, o r fax 978- 750- 4470. Library of Co ngress Catalo ging- in- Publicatio n Data

Pro ductio n: Ple ase supply CIP data. If CIP data is no t available, the bo o k sho uld have a Library of Co ngre ss Catalo g Card Numbe r inste ad; in such a case, ple ase de le te the pre ce ding he ading and add the LOC numbe r just above the ISBN o n this page

LIMIT OF LIABILITY/ DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES. Trade marks: All brand names and pro duct names used in this bo o k are trade names, service marks, trademarks, o r registered trademarks of their respective owners. IDG Bo o ks Wo rldwide is no t asso ciated with any pro duct o r vendo r mentio ned in this bo o k. is a registered trademark o r trademark under exclusive license to IDG Bo o ks Wo rldwide, Inc. fro m Internatio nal Data Gro up, Inc. in the United States and/ o r o ther co untries.

Welcome to the world of IDG Books Worldwide. IDG Books Worldwide, Inc., is a subsidiary of International Data Group, the world’s largest publisher of computer-related information and the leading global provider of information services on information technology. IDG was founded more than 30 years ago by Patrick J. McGovern and now employs more than 9,000 people worldwide. IDG publishes more than 290 computer publications in over 75 countries. More than 90 million people read one or more IDG publications each month. Launched in 1990, IDG Books Worldwide is today the #1 publisher of best-selling computer books in the United States. We are proud to have received eight awards from the Computer Press Association in recognition of editorial excellence and three from Computer Currents’ First Annual Readers’ Choice Awards. Our bestselling ...For Dummies® series has more than 50 million copies in print with translations in 31 languages. IDG Books Worldwide, through a joint venture with IDG’s Hi-Tech Beijing, became the first U.S. publisher to publish a computer book in the People’s Republic of China. In record time, IDG Books Worldwide has become the first choice for millions of readers around the world who want to learn how to better manage their businesses. Our mission is simple: Every one of our books is designed to bring extra value and skill-building instructions to the reader. Our books are written by experts who understand and care about our readers. The knowledge base of our editorial staff comes from years of experience in publishing, education, and journalism — experience we use to produce books to carry us into the new millennium. In short, we care about books, so we attract the best people. We devote special attention to details such as audience, interior design, use of icons, and illustrations. And because we use an efficient process of authoring, editing, and desktop publishing our books electronically, we can spend more time ensuring superior content and less time on the technicalities of making books. You can count on our commitment to deliver high-quality books at competitive prices on topics you want to read about. At IDG Books Worldwide, we continue in the IDG tradition of delivering quality for more than 30 years. You’ll find no better book on a subject than one from IDG Books Worldwide.

John Kilcullen Chairman and CEO IDG Books Worldwide, Inc.

Eighth Annual Computer Press Awards 1992

Ninth Annual Computer Press Awards 1993

Tenth Annual Computer Press Awards 1994

Eleventh Annual Computer Press Awards 1995

IDG is the world’s leading IT media, research and exposition company. Founded in 1964, IDG had 1997 revenues of $2.05 billion and has more than 9,000 employees worldwide. IDG offers the widest range of media options that reach IT buyers in 75 countries representing 95% of worldwide IT spending. IDG’s diverse product and services portfolio spans six key areas including print publishing, online publishing, expositions and conferences, market research, education and training, and global marketing services. More than 90 million people read one or more of IDG’s 290 magazines and newspapers, including IDG’s leading global brands — Computerworld, PC World, Network World, Macworld and the Channel World family of publications. IDG Books Worldwide is one of the fastest-growing computer book publishers in the world, with more than 700 titles in 36 languages. The “...For Dummies® ” series alone has more than 50 million copies in print. IDG offers online users the largest network of technology-specific Web sites around the world through IDG.net (http://www.idg.net), which comprises more than 225 targeted Web sites in 55 countries worldwide. International Data Corporation (IDC) is the world’s largest provider of information technology data, analysis and consulting, with research centers in over 41 countries and more than 400 research analysts worldwide. IDG World Expo is a leading producer of more than 168 globally branded conferences and expositions in 35 countries including E3 (Electronic Entertainment Expo), Macworld Expo, ComNet, Windows World Expo, ICE (Internet Commerce Expo), Agenda, DEMO, and Spotlight. IDG’s training subsidiary, ExecuTrain, is the world’s largest computer training company, with more than 230 locations worldwide and 785 training courses. IDG Marketing Services helps industry-leading IT companies build international brand recognition by developing global integrated marketing programs via IDG’s print, online and exposition products worldwide. Further information about the company can be found at www.idg.com. 1/26/00

Credit s Acquisit ions Edit or Greg Croy Project Edit or Terri Varveris Technical Edit or Sco tt Kinney Copy Edit ors Ro bert Campbell Sarah Kleinman Mildred Sanchez Proof Edit or Neil Ro mano sky Project Coordinat or Lo uigene A. Santo s Permissions Edit or Jessica Mo ntgo mery Media Development Specialist Laura Carpenter

Media Development Managers Stephen No etzel Heather Dismo re Graphics and Product ion Specialist s Ro bert Bihlmayer Jude Levinso n Michael Lewis Victo r Pérez- Varela Ramses Ramirez Qualit y Cont rol Technician Dina F Quan Book Designer Evan Deerfield I llust rat ors Brent Savage Gabriele McCann Proof reading and I ndexing Yo rk Pro ductio n Services

About t he Aut hor Gre g Pe rry is the autho r of mo re than 65 co mputer bo o ks and has so ld mo re than 2 millio n co pies of bo o ks wo rldwide. Perry has written o n to pics ranging fro m o perating systems, to pro gramming languages, to end- user applicatio ns. Befo re beco ming a full- time autho r and speaker, Perry wo rked as a Superviso r over financial systems at a Fo rtune 500 co mpany befo re moving fro m industry to teaching at the co llege level. In additio n to writing, Perry enjoys studying financial investing, traveling, and speaking o n numero us co mputer and travel subjects.

Fo r Mr. Le o Lapo rte, the co mpute r tuto r above all the o the r te ache rs.

Preface

W

elco me to HTML 4.01 We e ke nd Crash Co urse . So why ano ther HTML bo o k amo ng co untless HTML bo o ks? The We e ke nd Crash Co urse series is designed to give yo u quick access to the to pics yo u want to learn. Yo u wo n’t find a

to n of reference material in this bo o k. Instead, yo u will find the material yo u need to get the jo b do ne. Yo u are abo ut to experience the joy of delivering Web co ntent within Web pages that yo u design, create, and edit. No lo nger will yo u be sidelined as an Internet user o nly; yo u will now be part of the game, making yo ur own Web sites using the language that started it all: HTML.

Who Should Read This Book This crash co urse is designed to provide yo u with a set of sho rt lesso ns that yo u can grasp quickly — in o ne weekend. The bo o k is fo r two audience catego ries:

1 . Tho se who want to learn HTML fast. Yo u may need to learn HTML fo r employment o r yo u just want to create Web pages at ho me. Perhaps yo u are taking a co urse in HTML and need a quick supplement. If yo u are entirely new to pro gramming, rest easy because the 30 sessio ns assume no prio r knowledge of pro gramming. As lo ng as yo u’ve used the Internet to surf the Wo rld Wide Web, yo u are ready to learn and write HTML.

x

Preface

2 . Tho se who have so me knowledge of HTML, but who have no t written HTML co de in a while. HTML 4.01 offers improvements over earlier versio ns and this co urse refreshes yo ur knowledge, brings yo u up to date, and gives yo u back the co nfidence needed to use HTML. To get the mo st o ut of this bo o k, yo u sho uld be an experienced Internet user. I didn’t spend very much time writing basic how- to info rmatio n o n using a browser o r o n surfing Web pages. In fact, I assume that yo u know how to do the fo llowing:

쐌 Lo g o nto the Internet 쐌 Surf the Web 쐌 Lo cate info rmatio n yo u want to see o n the Web 쐌 Use an edito r ( if yo u’ve used a wo rd pro cesso r, yo u can use an edito r)

What You Need t o Have To make the best use of this bo o k, yo u need:

쐌 An Internet acco unt. 쐌 An edito r, such as Windows No tepad. Altho ugh a wo rd pro cesso r wo rks like an edito r, yo u need the mo re simple features that an edito r provides. A helpful Mac edito r is included in this bo o k’s CD- ROM.

쐌 A desire to learn HTML so that yo u can edit and create yo ur own Web pages. Any co mputer system with which yo u can lo g o nto the Internet wo rks. HTML do es no t require heavy pro cessing power. If yo u can view Web pages, yo u can create yo ur own Web pages with HTML. Yo u can use a mo dem co nnectio n o r a faster co nnectio n, such as a T1, T3, cable mo dem, o r DSL co nnectio n. The faster yo ur co nnectio n, the quicker yo ur HTML co de is lo aded and wo rking o n yo ur Web sites. However, a slow co nnectio n do es no t hinder yo ur ability to learn and use HTML effectively. I reco mmend that yo u use a high- reso lutio n video driver ( 800 × 600 is o kay, but

1024 × 768 is ideal) . A standard 600x480 VGA reso lutio n will do in a pinch, but the low reso lutio n generally limits what yo u can see at o ne time o n the screen.

What Result s Can You Expect ? Is it po ssible to learn HTML in a single weekend? Yes, it is. Unlike o ther kinds of pro gramming languages, HTML is simple and provides immediate feedback. Yo u

Preface

xi

do n’t have to send yo ur co de thro ugh a pro cess that co nverts it to so mething no t readable by humans. The co mputer understands the same HTML that yo u write. Therefo re, a co nversio n stage between yo u and the machine, called the co mpilatio n pro ce ss , is no t needed. This results in faster learning of HTML because less of a

wall separates yo u fro m the co mputer. This text is no t a reference bo o k. It do es no t teach yo u every aspect of every HTML co mmand. So metimes, yo u learn o nly eno ugh abo ut a co mmand to make it wo rk in the way that the majo rity of pro grammers use that co mmand. Also , yo u do no t have to tackle highly specific HTML co mmands that are rarely, if ever, used. In additio n to learning the HTML language, yo u also learn the co ntext of its use. Yo u do no t learn just the mechanics. Yo u learn why a certain HTML co mmand wo rks better than ano ther; why a certain Web page design dictates that yo u appro ach the HTML co de differently fro m usual; and why so me Web page design elements wo rk while o thers do no t. Yo u learn abo ut co lo r co mbinatio ns, graphic fo rmats, what appeals to the user’s eyes, how to write to different kinds of hardware, and yo u get a glimpse into future HTML- based techno lo gy that is likely to change the way yo u create Web pages.

Weekend Crash Course’s Layout and Feat ures This bo o k fo llows the standard Weekend Crash Co urse layo ut and includes the standard features of the series so that yo u can be assured of mastering HTML within a so lid weekend. Readers sho uld take breaks thro ugho ut. We’ve arranged things so that the 30 sessio ns last approximately o ne- half ho ur each. The sessio ns are gro uped within parts that take two o r three ho urs to co mplete. At the end of each sessio n, yo u’ll find “ Quiz Yo urself” questio ns, and. at the end of each part, yo u’ll find part review questio ns. These questio ns let yo u test yo ur knowledge and practice exercising yo ur newfo und skills. ( The answers to the part review questio ns are in Appendix A.) Between sessio ns, take a break, grab a snack, refill that beverage glass o r cup, befo re plunging into the next sessio n!

Layout This Weekend Crash Co urse co ntains 30, o ne- half- ho ur sessio ns o rganized within six parts. The parts co rrespo nd with a time during the weekend, as o utlined in the fo llowing sectio ns.

xii

Preface

Part I : Friday Evening In this part, I set the stage fo r the rest of the bo o k. Yo u’ll learn abo ut the reaso n fo r HTML. Yo u will learn abo ut the fo rmat of HTML co de and the interactio n between the user’s Web page and the HTML co de that yo u write.

Part I I : Sat urday Morning This part co nsists of six sessio ns that take yo u further into the wo rld of HTML pro gramming and its purpo se. Yo u learn how to add text to and fo rmat pictures o n yo ur Web pages. Yo u also master the inclusio n of hyperlnks, the links that co nnect Web co ntent.

Part I I I : Sat urday Aft ernoon In this afterno o n sessio n, yo u take yo ur HTML pro gramming to a new level by embedding email links into yo ur Web pages. Yo u see how to use tables to fo rmat yo ur Web pages into advanced and co nsistent co ntent that presents yo ur info rmatio n effectively. In additio n to tables, yo u also learn how to create fo rms o n o ur Web pages so that yo u can retrieve info rmatio n fro m visito rs.

Part I V: Sat urday Evening Here, yo u learn the next step in Web page pro ductio n. Now that yo u understand how to develo p Web pages, yo u now begin to explo re how to market and target yo ur Web page co ntent. Yo u learn how to lay o ut yo ur Web pages to make yo ur site mo re appealing to the visito rs who view yo ur site.

Part V: Sunday Morning This begins a two - part sectio n where yo u fo llow the develo pment of a family Web site fro m beginning to end. Yo u do no t start with HTML co ding because effective Web pages begin in the design ro o m. Once yo u have the design firmly in mind, yo u begin the HTML co ding pro cess. As yo u fo llow alo ng, yo u develo p the Web site and see how its genesis beco mes a finished pro duct.

xiii

Preface

Part VI : Sunday Aft ernoon In this part, yo u finish the family Web site’s pro ductio n and explo re so me ways to improve the site’s design and efficiency. In additio n, yo u learn how to co rrect po tential pro blems that can o ccur as well as how to stay o n to p of maintenance that is so critical in Web site develo pment.

Feat ures First, as yo u’re go thro ugh each sessio n, lo o k fo r the fo llowing time status ico ns that let yo u know how much pro gress yo u’ve made thro ugho ut the sessio n:

The bo o k also co ntains o ther ico ns that highlight special po ints of interest:

This is a f lag t o clue you in t o an import ant piece of informat ion t hat you should f ile away in your head for lat er. Not e

This gives you helpf ul advice on t he best ways t o do t hings, or a t ricky t echnique t hat can make your HTML programming go smoot her. Tip

Never fail t o check t hese it ems out because t hey provide warnings t hat you should consider. Never

This st at es where in t he ot her sessions relat ed mat erial can be found. Cross-Ref

xiv

Preface

Ot her Convent ions Apart fro m the ico ns yo u’ve just seen, o nly three o ther co nventio ns appear:

1 . To indicate a menu cho ice, I use the ➪ symbo l, as in:

Choose File ➪ Open to display a list of files. 2 . To indicate pro gramming co de o r an Internet address within the bo dy text, I use a special fo nt like this:

The Web site appears at http://www.idg.com/ and displays the corporate Web presence. 3 . To indicate a pro gramming example that’s no t in the bo dy text, I use this typeface:

Italy ice cream,

called gelato,

is the richest, creamiest ice cream in the world.

Buon Apitito!



Accompanying CD-ROM This Weekend Crash Co urse includes a CD- ROM in the back. The CD- ROM co ntains a skills assessment test, so urce co de fo r the lo nger examples in the bo o k, text edito rs, Netscape Navigato r, Internet Explo rer, and mo re. Fo r a co mplete descriptio n of each item o n the CD- ROM, see Appendix B.

Reach Out The publisher and I want yo ur feedback. After yo u have had a chance to use this bo o k, please take a mo ment to register this bo o k o n the http://my2cents.

idgbooks.com Web site. ( Details are listed o n the my2cents page in the back of this bo o k.) Please let us know of any mistakes in the bo o k o r if a to pic is covered particularly well. Please write to :

[email protected]

Preface

xv

Yo u are ready to begin yo ur weekend crash co urse. Stake o ut a weekend, sto ckpile so me snacks, co o l the beverage of yo ur cho ice, set yo ur seats in their upright po sitio ns, fasten yo ur belt, and get ready to learn HTML the easy way. Turn the page and begin learning.

Acknowledgment s

I

am extremely grateful to Jo e Wikert and Greg Croy, men who m I’ve wo rked with since the early days of my writing career. It’s like “ o ld ho me week” when we talk. By giving me the o ppo rtunity to write my first title fo r IDG, they

show a lo t of trust fo r which I’m extremely thankful. The edito r who wins the award fo r the mo st patience with my writing and with me is Terri Varveris. Terri, yo u are the best! Yo ur suggestio ns are precise and they make the bo o k so much better. Terri, I do n’t give yo u much go o d to wo rk with but yo u still turn my wo rds into readable text! In additio n, Mildred Sanchez, Sarah Kleinman, and Ro bert Campbell, all wo rked to gether to make this the best po ssible HTML bo o k o n the market. Mr. Sco tt Kinney stays busy with his premiere, wo rld- renown news and discussio n service Web site, MyRightStart.co m, yet he still made time to perfo rm the technical editing fo r this bo o k. Mr. Kinney is a leader in the Web industry, as well as being the co mmercial art field’s chief CEO with Kinney Creative, and it’s an ho no r to have a man of his caliber wo rk o n my writing. Of co urse, my mo st gratitude remains with my loving and suppo rtive bride, Jayne. My parents, Glen and Bettye Perry, co ntinue to suppo rt my wo rk in every way.

Cont ent s at a Glance Acknowledgment s ...................................................................................... xvii

FRI DAY....................................................................................................... 2 Part I – Friday Evening ............................................................................ 4 Sessio n Sessio n Sessio n Sessio n

1–HTML and the Web ..........................................................................5 2–HTML fo r Web Page Creatio n ............................................................17 3–Web Page Design ............................................................................31 4–Maintaining and Improving Yo ur Web Site.........................................43

SATURDAY ............................................................................................... 5 4 Part I I – Sat urday Morning ..................................................................... 5 6 Sessio n Sessio n Sessio n Sessio n Sessio n Sessio n

5–Text o n Yo ur HTML Page .................................................................57 6–Improving the Lo o k of Yo ur Web Page’s Text ......................................71 7–HTML Graphics ..............................................................................87 8–Wo rking with Co lo r in Text and Graphics .........................................101 9–Text and Graphics Organizatio n......................................................111 10–Hyperlinks Co nnect the Web ........................................................123

Part I I I – Sat urday Af t ernoon .............................................................. 1 3 8 Sessio n Sessio n Sessio n Sessio n Sessio n Sessio n

11–E- mail Links, Co mments, and Special Characters .............................139 12–Tables Organize Data...................................................................151 13–Fo rms Add Functio n ....................................................................167 14–Adding Fo rm Elements ................................................................181 15–Transparent Imaging ...................................................................197 16–Advanced Co lo r and Imaging Techniques .......................................209

Part I V– Sat urday Evening ................................................................... 2 2 4 Sessio n Sessio n Sessio n Sessio n

17–Marketing Yo ur Web Site with HTML .............................................225 18–Page Layo ut with Frames .............................................................235 19–Activating Pages with Multimedia and Ro llovers .............................249 20–Be Unifo rm with Style Sheets ......................................................267

SUNDAY................................................................................................. 2 8 6 Part V– Sunday Morning ...................................................................... 2 8 8 Sessio n Sessio n Sessio n Sessio n Sessio n Sessio n

21–Develo ping a Web Site fro m Scratch ..............................................289 22–Making the Web Site Ho me Page Lo o k Go o d ...................................299 23–The Web Site Ho me Page’s HTML...................................................309 24–The Web Site Ho me Page’s Text and Graphics..................................321 25–Creating and Co nnecting the Web Site’s Pages ................................333 26–Adding Special Elements to the Web Site .......................................349

Part VI – Sunday Af t ernoon ................................................................. 3 6 2 Sessio n Sessio n Sessio n Sessio n

27–Adding Other Special Elements to the Web Site ..............................363 28–Co rrecting Web Site Pro blems .......................................................377 29–Keeping the Family Web Site Fresh ...............................................389 30–The Future of HTML....................................................................403

Appendix A– Answers t o Part Reviews .......................................................... 4 1 3 Appendix B– What ’s On t he CD- ROM ............................................................. 4 2 1 I ndex ....................................................................................................... 4 2 5 End- User License Agreement ...................................................................... 4 4 8 CD- ROM I nst allat ion I nst ruct ions ................................................................ 4 5 2

Cont ent s Acknowledgment s................................................................................................ xvii

FRI DAY .................................................................................................................. 2 Part I – Friday Evening ..................................................................................... 4 Session 1 – HTML and t he Web ................................................................................. 5 Be come an HTML Programme r! ......................................................................... 6 What Exactly Is HTML? ..................................................................................... 7 HTML’s backgro und ........................................................................................8 HTML tags fo rmat data ...................................................................................9

Text Editors and Othe r Programs ..................................................................... 1 2 Session 2 – HTML for Web Page Creat ion ................................................................ 1 7 Cre ating a We b Page ....................................................................................... 1 7 Minimum HTML ...........................................................................................18 Viewing yo ur page........................................................................................20

Adding Formatting Command Tags .................................................................. 2 2 Head and title tags.......................................................................................22 Break tags...................................................................................................25 A mo re co mplete example .............................................................................26

The Browse r De te rmine s the Language ............................................................ 2 8 Session 3 – Web Page Design .................................................................................. 3 1 Conside ring Your Environme nt ....................................................................... 3 2 What’s an HTML pro grammer to do ? ...............................................................33 A wo rld witho ut images ................................................................................34

Validating Your Page ...................................................................................... 3 5 Initial De sign Conside rations .......................................................................... 3 6 Web structures.............................................................................................37 The Web page design walkthro ugh .................................................................38

Publishing We b Page s ..................................................................................... 4 0 Available Fre e Hosts ....................................................................................... 4 1 Session 4 – Maint aining and I mproving Your Web Sit e .......................................... 4 3 Succe ss Me ans Constant We b Site Mainte nance ................................................ 4 4 The Be st Way to Organize Your File s and Folde rs ............................................. 4 4 Should You Turn Your Compute r into a Local We b Se rve r? ................................ 4 5 The Eve r-Changing HTML................................................................................ 4 6

xxii

Cont ent s

HTML and Company ........................................................................................ 4 7 DHTML........................................................................................................47 XML ...........................................................................................................49 ActiveX co ntro ls ..........................................................................................49 CGI.............................................................................................................50 ASP............................................................................................................50

SATURDAY .......................................................................................................... 5 4 Part I I – Sat urday Morning ............................................................................. 5 6 Session 5 – Text on Your HTML Page ....................................................................... 5 7 Text Is the Foundation .................................................................................... 5 8 Your We b Page Ge ne ral Layout Te mplate ......................................................... 5 8 De aling with Spe cific Font Limitations ............................................................ 6 1 Specifying a fo nt .........................................................................................62 Graphic fo nts...............................................................................................65

Formatting Your Text with Command Tags ....................................................... 6 5 Presentable headlines ...................................................................................65 Fo nt size .....................................................................................................67 Character fo rmatting ....................................................................................68

Session 6 – I mproving t he Look of Your Web Page’s Text ....................................... 7 1 Text Alignme nt and Spacing ........................................................................... 7 1 Better paragraph spacing ..............................................................................72 Paragraph alignment ....................................................................................72 Line breaks and spacing ................................................................................74 Quo ting lo ng passages ..................................................................................75

Se parating Text with Horizontal Rule s ............................................................ 7 6 Bigge r and Smalle r Font Size s ......................................................................... 7 9 Additional Font Se le ction Conside rations ........................................................ 8 0 Putting Lists in Your Text ............................................................................... 8 1 Ordered lists ................................................................................................82 Uno rdered lists ............................................................................................82 Definitio n lists ............................................................................................83

Session 7 – HTML Graphics ..................................................................................... 8 7 Kinds of Graphics and File Type s .................................................................... 8 8 Working with Graphics ................................................................................... 8 9 Placing an image ..........................................................................................89 Framing an image ........................................................................................91 Aligning an image ........................................................................................91

Spe cifying the Image Size .............................................................................. 9 2 Whe n Use rs Turn Off the Image Display .......................................................... 9 5 Inte rlace d ve rsus Noninte rlace d Image s .......................................................... 9 7

Cont ent s

xxiii

Gamma Corre ction .......................................................................................... 9 9 Session 8 – Working wit h Color in Text and Graphics........................................... 1 0 1 Color Strate gie s: Code s and Safe Colors .......................................................... 1 0 2 Co lo r co des and palettes..............................................................................102 Browser- safe co lo rs .....................................................................................104

Spe cifying Browse r-Safe Colors ..................................................................... 1 0 5 The big 16 co lo rs ........................................................................................106 What abo ut tho se no nbrowser- safe co lo rs? ....................................................107

Adding Color to Text and Backgrounds .......................................................... 1 0 8 Session 9 – Text and Graphics Organizat ion ......................................................... 1 1 1 Aligning Image s and Text ............................................................................. 1 1 1 Ho rizo ntal image alignment.........................................................................113 Vertical image alignment .............................................................................114

Spacing Image s and Cre ating Horizontal Rule s .............................................. 1 1 6 Increasing image space ...............................................................................116 Creating yo ur own ho rizo ntal rules ...............................................................118

Using He adline and Background Image s ........................................................ 1 1 9 Headline graphics.......................................................................................119 Backgro und images.....................................................................................119

Session 1 0 – Hyperlinks Connect t he Web ........................................................... 1 2 3 URL Basics ................................................................................................... 1 2 3 Spe cifying Hype rlink Tags ............................................................................ 1 2 5 Co ntro lling hyperlink co lo rs ........................................................................128 Specifying hyperlink titles ..........................................................................128 Opening a new window ...............................................................................129 Specifying the tab o rder of hyperlinks ..........................................................130

Thumbnail Picture s ...................................................................................... 1 3 0 Inse rting Bookmarks to Links on the Same Page ........................................... 1 3 2 Absolute URLs ve rsus Re lative URLs .............................................................. 1 3 3

Part I I I – Sat urday Af t ernoon ..................................................................... 1 3 8 Session 1 1 – E- mail Links, Comment s, and Special Charact ers ............................ 1 3 9 Cre ating E-mail Links ................................................................................... 1 4 0 Uses fo r e- mail links ...................................................................................140 Specifying e- mail links ...............................................................................140

Adding Comme nts to HTML Code ................................................................... 1 4 2 Inse rting Spe cial Characte rs on We b Page s .................................................... 1 4 4 Session 1 2 – Tables Organize Dat a ....................................................................... 1 5 1 How Table s He lp You Organize Data ............................................................... 1 5 2 Pre paring Columnar Data Table s .................................................................... 1 5 3 Creating tables ...........................................................................................153 Specifying the header cells ..........................................................................154

xxiv

Cont ent s

Specifying the rows ....................................................................................155 Specifying the co lumns ...............................................................................156

Improving the Look of Your Table ................................................................. 1 5 7 Adding bo rders ..........................................................................................157 Aligning data ............................................................................................158 Spanning cells ...........................................................................................159

More Powe rful Table s .................................................................................... 1 6 1 Adding a backgro und co lo r to a table ............................................................161 Adjusting table spacing ...............................................................................161 Adjusting table space with percentages and multiple tables.............................162

Session 1 3 – Forms Add Funct ion ......................................................................... 1 6 7 Working With Forms ..................................................................................... 1 6 7 Yo ur Web ho st must help .............................................................................169 CGI retrieves yo ur data ...............................................................................170

Cre ating Forms ............................................................................................. 1 7 1 Adding text fields ......................................................................................172 Managing fo rm fields ..................................................................................174

Furthe r Fie ld Re fine me nt ............................................................................. 1 7 6 Large Text Are as ........................................................................................... 1 7 7 Session 1 4 – Adding Form Element s..................................................................... 1 8 1 Cre ating Che ck Boxe s .................................................................................... 1 8 1 Cre ating Radio Buttons ................................................................................. 1 8 4 Cre ating Se le ction Lists ................................................................................ 1 8 6 Displaying a selectio n list ...........................................................................187 Displaying a pick list ..................................................................................190

Submitting the Forms ................................................................................... 1 9 1 Creating the submit butto n .........................................................................192 Creating the reset butto n ............................................................................193

Session 1 5 – Transparent I maging ........................................................................ 1 9 7 About Transpare nt Image s ............................................................................ 1 9 8 Making Image s Transpare nt .......................................................................... 1 9 9 Transpare ncy Proble ms Cause d by Anti-Aliasing ............................................ 2 0 2 The One -Pixe l Transpare nt Image Trick ......................................................... 2 0 3 Spe cifying a Low-Re solution Prototype ......................................................... 2 0 5 Session 1 6 – Advanced Color and I maging Techniques ........................................ 2 0 9 A Proble m with Displaying Black-and-White Photos ...................................... 2 1 0 De sign Tip: White Works We ll ....................................................................... 2 1 1 Cre ating Navigation Bars .............................................................................. 2 1 3 Cre ating Banne rs for Style ............................................................................ 2 1 5 Bo rdering banners ......................................................................................215 Advertising and headline banners.................................................................218

Final Graphics Tips ....................................................................................... 2 1 9

Cont ent s

xxv

Part I V– Sat urday Evening .......................................................................... 2 2 4 Session 1 7 – Market ing Your Web Sit e wit h HTML ............................................... 2 2 5 Ge tting Your Site Notice d with Me ta Tags ...................................................... 2 2 6 The name= and co ntent= attributes ..............................................................227 Specifying keywo rds ...................................................................................228 Hiding fro m search engines .........................................................................228

Channe ling Your Product: The We b Site ......................................................... 2 2 9 Othe r Ways of Ge tting Your Site Notice d ........................................................ 2 3 0 Understand how search engines o perate ........................................................230 Registering with the co mmo n search sites .....................................................231 Using e- mail: spam o r attentio n- getter? ........................................................232 Hiring o utside help.....................................................................................232

Playing Me ta Tag Tricks ................................................................................ 2 3 2 Searching fo r co ntent .................................................................................232 Meta tag tricks...........................................................................................233

Session 1 8 – Page Layout wit h Frames................................................................. 2 3 5 Frame s Se parate We b Page Conte nt ............................................................... 2 3 5 Proble ms with Frame s .................................................................................. 2 3 8 Frame Cre ation Ste ps .................................................................................... 2 3 9 Step 1: Planning the frame- based page .........................................................239 Step 2: Creating the frame’s pages ................................................................240 Step 3: Generating the frame ho lding page ....................................................241

Frame -Base d HTML ....................................................................................... 2 4 2 Backgro und frame page ...............................................................................242 Linking the frames .....................................................................................244 Other frames can change .............................................................................246 Help fo r no n- frame browsers ........................................................................246

Session 1 9 – Act ivat ing Pages wit h Mult imedia and Rollovers ............................ 2 4 9 Spe e ding Up the Multime dia Proce ss with Bandwidth .................................... 2 5 0 Adding Sound to We b Page s .......................................................................... 2 5 0 So und with HTML.......................................................................................251 Better so und management ...........................................................................252

Adding Vide o to We b Page s ........................................................................... 2 5 3 Specifying external video clips.....................................................................254 Specifying internal video clips .....................................................................255

The Rollove r Effe ct ....................................................................................... 2 5 8 JavaScript- enabled .....................................................................................260 A quick ro llover example .............................................................................260

Session 2 0 – Be Uniform wit h St yle Sheet s ......................................................... 2 6 7 Introducing Style She e ts ............................................................................... 2 6 8 Befo re yo u co ntinue . . . ............................................................................268

xxvi

Cont ent s

Why use style sheets ..................................................................................269 The added advantages of CSS .......................................................................269

Introducing HTML Style s ............................................................................... 2 7 0 Typical style fo rmat ....................................................................................270 Useful style characteristics ..........................................................................270

Pre paring One of Two Style She e ts ................................................................ 2 7 3 Style sheets fo r individual Web pages ...........................................................274 One style sheet fo r multiple Web pages .........................................................275

Advance d Work with Style s ........................................................................... 2 7 7 Specifying style classes ...............................................................................277 Specify backgro und images and co lo rs ..........................................................279 Specifying exact pixel placement .................................................................281 Removing underlines fro m hyperlinks ...........................................................282

SUNDAY ........................................................................................................... 2 8 6 Part V– Sunday Morning .............................................................................. 2 8 8 Session 2 1 – Developing a Web Sit e f rom Scrat ch .............................................. 2 8 9 The We b Page Te am ...................................................................................... 2 9 0 Exploring Possible Site s and Strate gie s ......................................................... 2 9 2 Brainsto rming with the team .......................................................................292 Getting specifics fro m the client ..................................................................293

The Site ’s Ge ne ral Conte nt and Make -Up ....................................................... 2 9 4 General co ntent characteristics ....................................................................294 Page- by- page go als .....................................................................................295

Session 2 2 – Making t he Web Sit e Home Page Look Good ................................... 2 9 9 Cre ating the Logo ......................................................................................... 3 0 0 Cre ating the Prototype ................................................................................. 3 0 2 Table s or Frame s or Both? ............................................................................. 3 0 4 Pre paring for Table s ..................................................................................... 3 0 5 Se le cting Color Sche me ................................................................................. 3 0 7 Session 2 3 – The Web Sit e Home Page’s HTML ..................................................... 3 0 9 The Initial HTML Te mplate ............................................................................ 3 1 0 Docume nt the HTML Code ............................................................................. 3 1 1 Starting the He ade r Table ............................................................................. 3 1 3 Comple ting the He ade r Table ........................................................................ 3 1 6 Session 2 4 – The Web Sit e Home Page’s Text and Graphics.................................. 3 2 1 The Home Page ’s Bottom Table ...................................................................... 3 2 2 The Navigation Bar ....................................................................................... 3 2 4 The Final Two Columns: Image s and Text ....................................................... 3 2 6 Session 2 5 – Creat ing and Connect ing t he Web Sit e’s Pages ............................... 3 3 3 Ge tting the Barkleys’ Site Notice d by Se arch Engine s ..................................... 3 3 3

Cont ent s

xxvii

Turning the Logo into a Hype rlink ................................................................ 3 3 5 Linking the Thumbnails to Large r Image s ..................................................... 3 3 6 Linking the Navigation Bar and Cre ating Subse que nt Page s ........................... 3 3 8 Adding the links ........................................................................................339 Making Mo m’s Co rner ..................................................................................341 Making Dad’s Co rner ...................................................................................344

Session 2 6 – Adding Special Element s t o t he Web Sit e ....................................... 3 4 9 De ciding How to Place Picture s on the Family We b Page s ............................... 3 4 9 Cre ating the Family Picture Page with Graphics ............................................. 3 5 1 Cre ating the Kids’ Page with Frame s, Graphics, and Sound ............................. 3 5 4 Creating the frames ....................................................................................354 Creating the header frame, so und, and drawings ............................................356

Part VI – Sunday Af t ernoon ......................................................................... 3 6 2 Session 2 7 – Adding Ot her Special Element s t o t he Web Sit e ............................. 3 6 3 Cre ating the Favorite Movie s Page ................................................................. 3 6 3 Adding the Form to the Favorite Movie s Page ................................................ 3 6 8 Cre ating the Image Map for the Family Trave ls Page ...................................... 3 7 1 Session 2 8 – Correct ing Web Sit e Problems ......................................................... 3 7 7 Pote ntial Usability Proble ms and Statistics .................................................... 3 7 8 Pe rforming a Usability Study to De te rmine Cause .......................................... 3 8 0 Image Map Proble ms and Solutions ............................................................... 3 8 3 Image map pro blems ...................................................................................383

Session 2 9 – Keeping t he Family Web Sit e Fresh ................................................. 3 8 9 Fre shne ss Is the Key ..................................................................................... 3 9 0 Get quick HTML feedback ............................................................................390 Write the do cumentatio n ............................................................................391

The Barkleys’ Fully Docume nte d Home Page .................................................. 3 9 1 Improving the Way Text Is Pre se nte d ............................................................ 4 0 0 Session 3 0 – The Fut ure of HTML.......................................................................... 4 0 3 Growth Incre ase s De mand for HTML.............................................................. 4 0 4 New Hardware Brings HTML Challe nge s ......................................................... 4 0 4 Your Job Is to Ke e p Up with HTML-Re late d Te chnologie s ............................... 4 0 5 The Future : We bTV and PDAs ........................................................................ 4 0 6 WebTV device- based HTML...........................................................................407 PDA device- based HDML ..............................................................................408

Appendix A– Answers t o Part Reviews ................................................................. 4 1 3 Appendix B– What ’s On t he CD- ROM .................................................................... 4 2 1 I ndex ................................................................................................................... 4 2 5 End- User License Agreement .............................................................................. 4 4 8 CD- ROM I nst allat ion I nst ruct ions ....................................................................... 4 5 2

SESSI ON

1 HTML and t he Web

Session Checklist ✔ Learn the jo b of the HTML pro grammer ✔ Understand what HTML is and its purpo se ✔ Reco gnize how text edito rs and o ther pro grams wo rk to help create HTML

D

o yo u want to beco me an HTML pro grammer? If so , yo u must tackle HTML ( Hypertext Markup Language) . Fo rtunately, HTML 4.01 is mo re powerful than the versio ns that came befo re it, as well as much simpler to learn than

typical co mputer pro gramming languages such as C o r Visual Basic. As this weekend crash co urse proves, yo u can go fro m knowing no thing abo ut HTML to designing and pro ducing Web pages in o ne sho rt weekend. As yo u will see in this sessio n, the HTML language has go ne thro ugh several improvements and each revisio n serves to make Web pages mo re interactive with the user and to present data mo re effectively. That data can be text, graphics, so und, video , o r a co mbinatio n of all fo ur. Altho ugh to day’s HTML differs quite a bit fro m the first versio n, the majo rity of the o riginal language elements are still in use.

6

Friday Evening

So me peo ple say that yo u do n’t need HTML anymo re, and that to o many graphical Web page design to o ls exist that make HTML unnecessary. To set yo ur mind at ease co nsidering that yo u’ve now spent the mo ney fo r this co urse, yo u wo n’t find any serio us Web designer who do esn’t wo rk with HTML almo st daily. In additio n, as yo u will so o n learn, the Web wo uld no t and co uld no t even exist witho ut HTML.

Become an HTML Programmer! An HTML pro grammer designs, pro duces, and maintains Web pages. As yo u know fro m surfing the Web already, mo st Web sites are no t single Web pages but co llectio ns of pages. A Web site co nsists of a series of related Web pages that users traverse, backwards and fo rwards, in virtually any o rder. The HTML pro grammer’s jo b changes almo st daily. A pro grammer might find himself o r herself perfo rming o ne o r mo re of the fo llowing HTML- related tasks daily:

쐌 Designing new Web pages fo r their clients who want to present info rmatio n o n the Web

쐌 Learning new HTML extensio ns, to o ls, and tricks that help get the Webmastering jo b do ne faster and mo re accurately

쐌 Maintaining existing Web sites by editing the co de to co rrect pro blems and to present fresh material

The more of t en you put f resh mat erial on a Web sit e, t he more likely users are t o ret urn t o t he sit e. Tip

Not e

The t erm maint enance ref ers t o t he process of changing and updat ing exist ing Web sit es t o keep t heir cont ent f resh, and correct ing mist akes found in t hem. Those mist akes might be t ypical comput er bugs t hat keep t he Web sit e f rom operat ing exact ly right or may be not hing more t han a spelling mist ake or a color- blending problem f rom a bad graphic image.

Perhaps yo u want to create Web pages fo r yo ur co mpany’s business. Perhaps yo u want to put yo ur family news o n the Internet so friends and family aro und the wo rld will be able to see the news. Perhaps yo u want to make mo ney — a lo t

Session 1 — HTML and t he Web

7

of mo ney — and the Internet is the ho ttest place fo r that right now. HTML pro grammers are in great demand, and that demand seems to be increasing. So do n than 30 ho urs.

What Exact ly I s HTML? The name HTML stands fo r Hype rte xt Markup Language. That’s a mo uthful. Many peo ple who create Web pages and wo rk in HTML often fo rget what the letters stand fo r. The term’s hypertext po rtio n refers to the cro ss- links, also called hyperlinks, between Web pages. The term’s markup language po rtio n refers to the co mmands that fo rmat the Web pages that the users see. Knowing how to write and use HTML is the go al, no t remembering the archaic abbreviatio n.

The t erm HTML language is as redundant as ATM machine and PI N number. Lit erally, HTML language means Hypert ext Markup Language language. Redundant or not , HTML language is of t en Not e

t he phrase used, even by experienced HTML programmers.

The Internet is mo re than just a bunch of Web pages. The Internet co nsists of Web pages, e- mail, text, vo ice, video chat sessio ns, and an asso rtment of o ther tasks that often hide behind the scenes fro m typical Internet users. Amidst the array of Internet co mpo nents, a Web page co mprises the mo st impo rtant piece of the Internet because a Web page is the user interface to the info rmatio n that resides o n the Internet. Clo se to o ne billio n Web pages co mprise the Wo rld Wide Web ( WWW) . Virtually every Web page that yo u’ve ever visited has two things in co mmo n:

쐌 They co ntain fo rmatted text and graphic images. 쐌 They are created, in who le o r in part, using the HTML language. It may surprise yo u to learn that HTML is a language that has abso lutely no fo rmatted text o r graphic images. The HTML language co nsists so lely of unfo rmatted text. That text, however, co ntains instructio ns, called tags o r co mmand tags, that define exactly how fo rmatted text and graphics appear o n Internet Web pages. In o ther wo rds, HTML determines how a Web page browser displays the info rmatio n yo ur HTML- based Web pages pro duce.

Part I — Friday Evening Session 1

yo ur thinking caps because a who le new skill set is abo ut to be yo urs in fewer

8

Friday Evening

Not e

I n ot her comput er languages, t he t erm program means a set of inst ruct ions t hat makes t he comput er perform a specif ic t ask, such as payroll processing. A Web page’s HTML set of t ag commands is usually ref erred t o as HTML code. HTML is more of a format t ing language t han a programming language. Some ext ensions in recent versions of HTML can be considered t iny programs, but t he t erm program is rarely used for HTML code.

HTML’s background HTML’s genesis is interesting. Unlike the o rigin of many co mputer languages, understanding HTML requires knowing a little abo ut the necessity that bro ught abo ut the HTML language in the first place. HTML is o nly abo ut a decade o ld and fo r mo st of that decade, HTML simply fo rmatted text pages viewable by o nly a few browsing pro grams. The o riginal go al of HTML was to present textual info rmatio n that wo uld enable users to jump, o r hyperlink, between areas of interest. In additio n, HTML offered a metho d fo r fo rmatting text sent between co mputers. To day, HTML’s latest incarnatio n, currently at versio n 4.01, no t o nly fo rmats text but also presents graphics and manages fo rms of data between co mputers. The HTML co nventio n is so widely used that o nline help systems, intrane ts ( netwo rked co mputers tied to gether at single lo catio ns as o ppo sed to being co nnected so lely to the Wo rld Wide Web) , CD- ROM interfaces, and o ther uses of HTML are co mmo nplace. As sites such as FreeBo o ks.co m ( http://www.freebooks.com/) demo nstrate, yo u can downlo ad co mplete bo o ks fo rmatted in the HTML language that yo u can, in turn, o pen and read directly fro m within yo ur Internet browsing pro gram such as Netscape Navigato r, Internet Explo rer, o r UNIX browsers. The true beauty of HTML is that any co mputer with a Web browser can read and interpret HTML co de o n inco ming Web pages. Befo re the standardized HTML ( which is no t yet a true industry standard because of all the HTML extensio ns flo ating aro und) , a co mputer co uld receive o nly data fro m a similar machine, o r straight text data o nly. Given that HTML is straight, unfo rmatted text, simple transfer pro to co ls still enable any kind of co mputer to read and display a Web page pro perly. Befo re the Internet became po pular, o ne wo uld send different kinds of files over a netwo rk co nnectio n. Yo u might send a text file to a friend and then send a graphics file. Perhaps yo u downlo aded a so und file fro m an electro nic bulletin bo ard system ( a BBS) . To day, yo u can still downlo ad files in vario us fo rmats, but, in additio n, yo u receive an HTML- based file when yo u view a Web page. One of the advantages of sending HTML over a co nnectio n, as well as individual data files, is

9

Session 1 — HTML and t he Web

that the HTML co de ties all the o ther data elements to gether by fo rmatting them into a readable and useable Web page.

HTML t ags format dat a Yo u’re already mo re than a third thro ugh this first sessio n, and yo u haven’t seen o ne line of HTML co de. It is time! With o nly 30 ho urs of training, the so o ner yo u learn HTML co de, the better. Listing 1- 1 co ntains HTML co de that pro duces the to p po rtio n of a Web page. At this po int, the HTML co de may lo o k rather fo rebo ding. HTML co de is co mprised of a series of co mmands called tags that describe the lo o k of the resulting Web page.

Listing 1 -1 The to p po rtio n of a We b page cre ate d with HTML

( fo r table row) tag and co lumns with the Make Money Now 52 $22.95
Co ntinue d

Part I — Friday Evening Session 1

Not e

I f you or a user of your Web pages uses a browser t hat does not support HTML version 4 .0 1 , but inst ead support s a lower version, t hat older browser should, but does not always, ignore t he newer and unrecognized HTML language commands in your Web page. Alt hough some browsers may display error messages, most simply ignore t he HTML command, result ing in your Web page looking dif f erent f rom your expect at ions. The vast majorit y of users use I nt ernet Explorer or Net scape Navigat or. These t wo browsers, depending on how current t he version is, provide excellent support for t he HTML language and it s ext ensions.

10

Friday Evening

Listing 1 -1

Co ntinue d

Figure 1- 1 shows yo u what Listing 1- 1’s HTML co de pro duces inside a browser window. The result is much mo re appealing and fancier than the HTML co de. That’s actually the beauty of HTML; the better trained yo u are in HTML, the mo re appealing yo ur resulting Web pages will lo o k and the mo re users will return to yo ur sites — and the mo re in demand yo u will be as an HTML pro grammer. Do n’t expect to understand much of the co nnectio n between the HTML co de, called so urce co de, in Listing 1- 1, and the results shown in Figure 1- 1. At this po int, yo ur jo b is to understand the purpo se of HTML and no t wo rry abo ut the meaning of the individual co mmand tags. HTML tells the receiving browser how to lo cate and fo rmat any type of data fo und o n the Internet, including text, graphics, so und, and video .

Never

You never have t o purchase a new version of HTML. Unlike t ypical programming languages such as Visual Basic, which you must updat e as each new language version is released, you can creat e Web pages t hat cont ain all t he lat est and great est HTML ext ensions wit h simple t ools t hat come wit h Windows. The browser t hat reads HTML code det ermines which new language ext ensions t he user experiences when a Web page you creat e appears on t he user’s screen.

Session 1 — HTML and t he Web

11

Part I — Friday Evening Session 1

Figure 1-1 The We b page appe ars cle an and we ll-fo rmatte d thanks to pro pe r HTML co de.

Obvio usly, if Listing 1- 1 is a co mplete and accurate set of HTML co de that pro duces a Web page, yo u o nly need a text edito r, perhaps o ne such as the UNIX vi edito r o r No tepad ( that co mes with Windows) , to enter and write HTML co de. A huge number of HTML pro grammers rely o n simple text edito rs such as these to enter and write HTML co de. Altho ugh o ther pro grams exist, as yo u’ll see later in this sessio n, text edito rs, such as No tepad, are always available o n any Windows co mputer. If yo u’re wo ndering where the fancy fo rmatted text and graphics are in Listing 1- 1’s HTML co de, the mystery is that no fo rmatted text and graphics ever appear inside the actual HTML co de. The Web browser must read the co de in Listing 1- 1 befo re yo ur users will see results. In o ther wo rds, when a Web browser is sent a file co ntaining HTML co de, instead of displaying that actual co de, the browser interprets the co mmands inside the file and acts acco rdingly.

12

Friday Evening

Text Edit ors and Ot her Programs As mentio ned in the previo us sectio n, No tepad ( fo und o n the Windows Pro grams ➪ Accesso ries menu) is a useful to o l fo r creating HTML co de o n Windows machines. ( Mac users often use SimpleText and Stickies o r BBEdit fo r HTML co ding.) These pro grams are called e dito rs o r te xt e dito rs. A text edito r is like a po o r- man’s wo rd pro cesso r. With a text edito r, yo u can enter and edit text. However, the text edito r do es no t fo rmat lines, sentences, o r paragraphs, and often igno res spelling erro rs.

Not e

Programmers who writ e t ext - based programs need t heir edit ors t o ret ain line breaks and not wrap lines, as word processors do. I n addit ion, f eat ures such as aut omat ic spelling correct ion would change many programming commands t o words t hat are meaningless t o t he comput er t rying t o run t he program. Simple t ext edit ors are t he t ools of t he t rade for t ext - based programming.

Befo re the Web came alo ng, pro grams such as No tepad were go ing the way of mo no chro me PC mo nito rs. Why wo uld anyo ne use a text edito r in the wo rld of graphical user interfaces ( GUIs ) ? Fo r PC users, with Windows co ming o n the scene, straight text was o n its way o ut, and mo re feature- packed wo rd pro cesso rs such as Wo rd filled the vo id. Text edito rs co uld no t handle the pro grammer’s new respo nsibilities that required interfacing graphics and text. Fo rtunately, Micro soft kept No tepad in its Windows bag of tricks fo r o ne versio n lo nger than mo st wo uld think necessary. While Windows 3.1 was making its way o nto the wo rld’s co mputer deskto ps, a little- known netwo rk called the Internet was leveling the pathways to build the info rmatio n superhighway. The co ncrete used fo r that info rmatio n superhighway was the earliest versio n of HTML, which required no thing mo re than a simple text edito r. As mo re and mo re peo ple began using the Internet, mo re and mo re pro grammers learned HTML. These pro grammers had a cho ice to make: Either spend mo ney o n co mmercial text edito rs o r use the freebie, such as No tepad, that came with every PC in the wo rld. Needless to say, No tepad saw new life, and Web pro grammers are still using No tepad and its co usins o n o ther kinds of co mputers to day. Figure 1- 2 shows a No tepad editing sessio n at wo rk o n an HTML Web do cument.

Session 1 — HTML and t he Web

13

Part I — Friday Evening Session 1

Figure 1-2 No te pad is a ne ar-pe rfe ct and simple to o l fo r writing HTML co de.

Edito rs such as vi and No tepad are extremely simple. Their beauty is also their flaw because that simplicity do es lack features that wo uld be nice fo r HTML pro grammers, such as a spelling checker fo r specific HTML co de tags o r auto matic indentio n of sectio ns of HTML co de that go to gether to make the co de mo re readable. These simple text edito rs are igno rant of HTML o r any o ther pro gramming language and offer no HTML- specific features.. Co mmercial edito rs, o n the o ther hand, offer specific features, and that is why so many to o ls exist o n the market to day fo r HTML pro gramming and Web autho ring. In spite of the heavy co mpetitio n, a huge number of HTML pro grammers still utilize No tepad and o ther simple text edito rs fo r quick edits and so metimes fo r their entire pro gramming pro cess.

Tip

Microsof t Word has made a complet e circle in it s support for HTML. Word is not a great word processor for writ ing st raight HTML t ext , but Word is nice for format t ing t ext and laying out graphics on a page. You can save a Word document in HTML format and t hen edit t he HTML code t o make t he Web page look exact ly t he way you want it t o look.

14

Friday Evening

One reaso n HTML pro grammers began to use o ther, co mmercial edito rs, such as Fro ntPage 2000 and Dreamweaver, is that they do no t begin with the textual HTML co de. Fo r example, Figure 1- 3 shows a screen sho t of a Web page, created with Fro ntPage. Where’s the HTML co de?

Figure 1-3 A scre e n sho t of a We b page cre ate d with Fro ntPage do e s no t display co de.

Develo pment pro grams such as Fro ntPage 2000 and Dreamweaver are graphical in nature. Initially, yo u design Web pages graphically by specifying where text and graphics will appear, by drawing lines and boxes with the editing to o ls, and by impo rting data that yo u want to appear in yo ur Web page. As yo u design yo ur Web page, Fro ntPage 2000 and the o ther graphical- develo pment to o ls write the HTML co de in the backgro und. At any po int, yo u can click yo ur mo use to see the HTML co de behind the Web page yo u are creating. Figure 1- 4 shows the HTML co de used fo r the Web page in Figure 1- 3. In this case, the page’s autho r had to do abso lutely no thing to write the HTML co de. As a matter of fact, so me pro grammers use pro grams such as Dreamweaver o r Fro ntPage 2000 to design Web pages, and they never write o r lo o k at a single line of HTML co de the entire time, fro m design to the Internet.

Session 1 — HTML and t he Web

15

Part I — Friday Evening Session 1

Figure 1-4 Fro ntPage write s the HTML co de in the backgro und as yo u de sign the We b page.

At this po int, perhaps yo u are co nfused, and if so , fo r go o d reaso n. The first part of this sessio n stressed the need fo r yo u to learn HTML, and now yo u’re seeing to o ls that seem to eliminate the need to know HTML. The pro s all know HTML, regardless of the fact that they mo stly all use graphical develo pment systems such as Dreamweaver fo r much of their Web page develo pment. The reaso n is simple: With power co mes lack of flexibility. Altho ugh these develo pment to o ls co ntain super to o ls fo r placing yo ur general Web page elements and text, they rare ly do exactly what yo u want them to do . With almo st a billio n Web pages o n the Internet, the search is o n fo r uniqueness amo ng sites. If everybo dy used Fro ntPage 2000 and did no t bo ther learning HTML co de, all Web pages wo uld lo o k so mewhat alike. No t that Fro ntPage 2000 lacks rich features that enable yo u to design smashing Web pages. But it simply do es no t co ntain an unlimited feature set. Practical limits placed o n develo pment to o ls mean that if yo u truly want to fine- tune yo ur Web sites so they sing, yo u must master HTML. The Web sites that lo o k amateurish are almo st all designed by HTML pro grammers who used develo pment to o ls but either didn’t take the time to

16

Friday Evening

ho ne the site’s design by wo rking over the auto matically- created HTML co de, o r didn’t know eno ugh HTML to do mo re than the standard co o kie- cutter Web site. Want pro of? Spend the next 29 ho urs o r so learning how yo u can use HTML to make yo ur Web sites ro ck.

REVI EW 쐌 HTML pro gramming requires knowledge of Web page design, creatio n, and maintenance.

쐌 쐌 쐌 쐌

Users return again and again to Web sites that maintain fresh co ntent. HTML plays a vital ro le in Web page design. HTML co ntains co mmand tags that fo rmat Web pages. Web page designing pro grams, such as Fro ntPage, are powerful but still require knowledge of HTML fo r pro per Web page design.

QUI Z YOURSELF 1.

Why do es the HTML pro grammer’s jo b require mo re than just the creatio n of new Web sites? ( See “ Beco me an HTML Pro grammer! ” )

2.

What do es the abbreviatio n fo r HTML stand fo r? ( See “ What Exactly is HTML?” )

3.

HTML co de co ntains the graphics and fo rmatted text that co mprise Web pages. True o r False? ( See “ HTML Tags Fo rmat Data.” )

4.

Why is No tepad still in use by so me HTML pro grammers? ( See “ Text Edito rs and Other Pro grams.” )

5.

How can a Web page develo pment system, such as Fro ntPage 2000, help and hinder autho rs of the Web? ( See “ Text Edito rs and Other Pro grams.” )

SESSI ON

2 HTML for Web Page Creat ion

Session Checklist ✔ Create yo ur first Web page ✔ Learn the minimum HTML co de to pro duce a Web page ✔ Understand basic HTML fo rmatting co mmand tags ✔ Understand that browsers do no t suppo rt the same HTML co de

o u begin this sessio n by creating yo ur very first Web page fro m scratch

Y

( actually, fro m HTML! ) using an edito r such as the Windows 98 No tepad edito r. Altho ugh the page will be extremely simple, the experience will teach

yo u much mo re abo ut the nature of HTML pro gramming than several chapters of text co uld do . HTML defines the styles of yo ur Web pages. Yo u’ll begin the example in this sessio n by explo ring the simplest jo b of HTML, text fo rmatting, and yo u’ll learn the bare- bo nes HTML co de required by Web pages.

Creat ing a Web Page As yo u learned in the first sessio n, HTML is a language that defines how yo ur Web page will lo o k. In o ne sense, HTML is a text- fo rmatting language. Altho ugh HTML

18

Friday Evening

do es mo re than fo rmat text, when the first versio n of HTML appeared, text fo rmatting was its primary jo b, seco nd o nly to providing hyperlinks as cro ss- references to o ther HTML do cuments. When yo u first learn HTML, perhaps the best place to begin is by fo rmatting so me simple text. Therefo re, co nsider the fo llowing po em: Ro ses are red, The Web is sure growing. Yo u use HTML, To keep yo ur page flowing. If yo u want to put this po em o n a Web page, co mpletely unfo rmatted, yo u co uld no t do so witho ut using so me HTML. In o ther wo rds, every Web page requires a minimum amo unt of HTML co de. Witho ut the minimum HTML tags, the file wo uld be no different fro m an o rdinary text file, such as a text file that might end with the txt filename extensio n. Given that HTML is a language co mprised of co mmand tags, as yo u learned in the previo us sessio n, yo u must insert mo re advanced fo rmatting tags aro und this po em befo re the po em can ever appear fo rmatted o n a Web page.

Minimum HTML This sectio n teaches yo u the minimal HTML co de needed to pro duce a Web page and how the co de sho uld be set up. Keep in mind that the minimum co de lets yo u create o nly an unfo rmatted Web page. Fo rmatting co mmand tags will be covered later in this sessio n.

Filename Ext ension A Web page, defined in an HTML file, always has the filename extensio n html ( o r htm if yo u want to be co mpatible with Windows 3 x users, altho ugh fewer and fewer of them exist) . The html extensio n separates the file type fro m o rdinary, unfo rmatted text files who se extensio ns might be txt. Many browsers, such as Internet Explo rer, will refuse to o pen yo ur file with an extensio n such as txt, except by starting ano ther pro gram such as No tepad and lo ading the text file into that seco ndary pro gram fo r yo ur viewing and editing wo rk. So me browsers will o pen a file who se name do es no t end with the html extensio n, but will refuse to interpret any HTML co mmand tags. In such a case, the file will appear inside the browser window displaying the nitty-gritty co mmand tags themselves instead of perfo rming the fo rmatting actio ns that the co mmand tags request.

Session 2 — HTML for Web Page Creat ion

19

Beginning and Ending and Tags Every Web page sho uld begin with the fo llowing HTML start tag:

Every Web page sho uld end with the fo llowing HTML end tag:

The po em, therefo re, lo o ks like this with tho se two enclo sing tags:

Roses are red, The Web is sure growing. You can use HTML, To keep your page flowing.

Mo re is needed to make this an appealing Web page.

Not e

All HTML t ags are enclosed bet ween angled bracket s. Of t en, relat ed t ags appear in pairs wit h one beginning t he format t ing process and t he ot her t erminat ing t hat format . The and t ags indicat e t he very beginning and ending of a Web page. The end t ag cont ains t he same command name as t he st art t ag except it begins wit h a forward slash t o dist inguish where t he t ag pair begins and ends.

The start and end tags may o r may no t be o n the same line. Fo r example, take the fo llowing sectio n of HTML co de:

This is boldface text

This example is identical to the fo llowing example in the way a browser handles it:

This is boldface text It is co mmo n to nest tag pairs inside o ther tag pairs. By do ing so , yo u can bo ldface wo rds inside a Web page’s italicized bo dy of text. Therefo re, do n’t be surprised to see many co mmand tags begin befo re yo u see the first end tag.

Part I — Friday Evening Session 2

20

Friday Evening

Lowercase Versus Uppercase in Tags It is co mmo n to use lowercase fo r all HTML tags. Mo st browsers and co mputers do no t care if the tag is uppercase, as yo u saw in the previo us sessio n’s example. Uppercase tags can help yo u keep the tags mo re easily separated fro m the surro unding text that the tags fo rmat. Nevertheless, a move is underway to standardize using lowercase tags because so me co mputers, mo st no tably UNIX- based machines, often distinguish to o literally between uppercase and lowercase in co mmand names. To be safe, develo p a go o d habit and write lowercase tags.

Spaces in Code Yo u may no t use spaces between a tag’s o pening angled bracket, its fo rward slash ( if it is an end tag) , o r befo re the co mmand itself. Many co mmands, however, include spaces bo th in the co mmand as well as in the co mmand’s attribute, which is an o ptio nal value that so me tags suppo rt. Fo r example, here is a valid co mmand tag with a space that separates the tag name fro m its attribute:

The fo llowing is illegal in many browsers because of the lo catio n of the first space:

< a href=”http://www.abc.org/image.jpg”> The reaso n the spacing aro und the co mmand tag’s angled brackets and the co mmand itself is so critical is that yo u do no t want yo ur browser mistaking no rmal text fo r a tag. If angled brackets appear in yo ur Web page’s text that is to be displayed, tho se angled brackets will no t be interpreted as po ssible HTML co mmand tags unless they fo llow an exact fo rmat required by HTML. Also , many times yo u will see quo tatio n marks aro und attributes, as shown in the previo us example. The quo tes are often o ptio nal.

Viewing your page If yo u want to view the Web page with the po em, do the fo llowing:

1.

Start No tepad.

2.

Type the po em in the previo us sectio n with the and tags.

3.

Save yo ur text file with the html extensio n so yo ur Internet browser can display the file pro perly.

Session 2 — HTML for Web Page Creat ion

21

Not e

4.

Start yo ur Web browser. Fro m a browser, yo u can o pen files o n yo ur own co mputer just as yo u o pen Web pages o n o ther co mputers over the Internet.

5.

Select File ➪ Open and type the full path and filename o r browse yo ur files fo r the file yo u saved earlier. Then click OK.

When yo u click OK, the po em is displayed alo ng the to p of the browser window, as shown in Figure 2- 1.

Figure 2-1 Yo ur HTML file appe ars in yo ur browse r’s window.

As yo u can see, the po em all rests o n a single line, even tho ugh the po em spans fo ur lines of yo ur HTML file. Web browsers do no t, and sho uld no t, make assumptio ns abo ut line and paragraph spacing. Yo u will learn how to separate the po em o nto different lines with the fo rmatting co mmands, which are discussed in the next sectio n. Keep in mind that if yo u do no t issue fo rmatting co mmands, the browser will perfo rm no fo rmatting o n the data yo u send to the browser.

Part I — Friday Evening Session 2

You can even use a word processor t o creat e your HTML code, but be sure t hat you save t he f ile in t ext format and use t he ht ml f ilename ext ension.

22

Friday Evening

Not e

You can use a general t ext edit or or one designed specif ically for HTML coding. One of t he nice t hings about a t ext edit or designed for HTML, as opposed t o a st raight t ext edit or such as vi or Not epad, is t hat many of t oday’s HTML edit ors color- code t ags t o help you keep your code accurat e. For example, BBEdit and Front Page 2 0 0 0 ’s HTML edit ing windows color all commands one color, command opt ions ( such as Tit le values) in anot her color, and cert ain punct uat ion and auxiliary HTML t ags in anot her color. Once you familiarize yourself wit h t hese color schemes, you will be able t o glance t hrough your HTML code on t he screen and more quickly locat e lines and commands t hat you want t o edit .

Adding Format t ing Command Tags Co ngratulatio ns, yo u have created yo ur first Web page. Obvio usly, yo u have a ways to go befo re yo u create the next do t.co m Web- based co mpany, but yo u’ve taken yo ur first step. Yo u can see that a simple Web page requires little mo re than typing text surro unded by and co mmand tags.

Head and t it le t ags One o ptio nal but crucial item yo u must add to every Web page that yo u create fro m this po int fo rward is a title fo r the browser window in which yo ur Web page appears. Yo u are pro bably used to seeing the title at the to p of almo st every Web site yo u visit. The title defines the page and so metimes displays needed info rmatio n such as a filename reference.

Never

Never let t he Web browser pick a window t it le for you. By default , t he HTML f ilename appears in t he t it le bar, if you don’t assign a t it le name. For example, t he t it le shown in Figure 2 - 1 is t he same as t he HTML f ilename displayed t o t he lef t of t he browser name. You owe it t o your Web audience t o describe as much as you can about t he page t hey are viewing. Users who view mult iple Web sit es on t heir screens at t he same t ime can read t he t iled windows’ t it les t o det ermine what each window cont ains.

The title co mmand tag must appear inside a special sectio n of yo ur Web page called the he ade r se ctio n. Befo re adding the title’s tags, yo u must first create the

Session 2 — HTML for Web Page Creat ion

23

header sectio n with the and co mmand tags. Start these tags immediately after the o pening tag, like this:

Tip

Add ample spacing t o make your HTML f iles readable and t o make t he command t ags and HTML sect ions pronounced. Subsequent HTML examples in t his weekend course include plent y of t his whit espace t o make t he f ile readable and easy t o maint ain.

As in wo rd pro cessing, the header sectio n of a Web page co ntains info rmatio n abo ut the Web page that often do es no t change fro m page to page o n the site. Mo st Web sites co ntain multiple pages, and the header sectio n defines the title and o ther heading info rmatio n fo r each page o n the site. The mo st impo rtant element yo u can include is the browser window title tag, , and its co rrespo nding end tag, . The value that yo u type between the title tags beco mes the actual title yo u want the Web browser to display in the browser window’s title bar.

Poem to make you feel good

Roses are red, The Web is sure growing. You can use HTML, To keep your page flowing.

Figure 2- 2 shows the resulting browser window. The browser window displays the po em’s title, “ Po em to make yo u feel go o d.”

Part I — Friday Evening Session 2



Roses are red, The Web is sure growing. You can use HTML, To keep your page flowing.

24

Friday Evening

The window's t it le

Figure 2-2 The title de scribe s the file to yo ur We b audie nce.

Finally, mo st HTML pro grammers place the bo dy of the Web page in its own sectio n, the bo dy se ctio n. As yo u see fro m the successful display of the Web page in Figure 2- 2, a bo dy sectio n is no t required fo r simple Web pages such as the o ne being created so far. Nevertheless, the bo dy sectio n helps yo u o rganize mo re advanced Web pages, and mo st HTML pro grammers agree that a bare- bo nes Web page sho uld include the and co mmand tags. The bo dy sectio n is the page’s meat- and- po tato es sectio n that co ntains the bulk of info rmatio n o n that page. The bo dy sectio n fo llows the header. The sample HTML- based po em now lo o ks like this:

Poem to make you feel good

Roses are red,

Session 2 — HTML for Web Page Creat ion

25

Break t ags As mentio ned in the previo us sectio n, the po em sho uld appear with each line o n a separate physical screen line. As yo u may now assume, a new co mmand tag is required. Use the bre ak tag to break lines. The fo rmat of the tag is as fo llows:


Text that appears on its own line The
tag is special because, unlike so many o ther co mmand tags,
has no co rrespo nding end tag. The
tag is a stand- alo ne tag because it requests that the browser move down to the next line o n the screen befo re displaying the text that fo llows. Adding
to the beginning of each line in the po em pro duces a fo ur- line po em. Here is the co mplete HTML file:

Poem to make you feel good


Roses are red,
The Web is sure growing.
You can use HTML,
To keep your page flowing.

Figure 2- 3 shows the final Web page creatio n. The po em is now fo rmatted and includes a title and a bo dy.

Part I — Friday Evening Session 2

The Web is sure growing. You can use HTML, To keep your page flowing.

26

Friday Evening




breaks lines here

Figure 2-3 Yo u’ve now se e n the co mple te cre atio n of a simple We b page.

Not e

The
t ag creat es a line break at each locat ion in which it is placed. The f irst line of t he poem would appear one line higher wit hout t he
t ag in f ront of it . You can put t he
t ag at t he end of a line t o force a line break for subsequent t ext .

A more complet e example To help initiate yo u into HTML, Listing 2- 1 co ntains the co de fo r a mo re co mplete HTML example with a graphic image. Altho ugh the example is no t extremely co mplex o r advanced, by studying the co de and the co rrespo nding Web page in Figure 2- 4 yo u will gain insight into what’s ahead in the late Friday evening and early Saturday sessio ns of this co urse. Think of this example as whetting yo ur appetite fo r mo re advanced HTML co mmands.

Session 2 — HTML for Web Page Creat ion

27

Listing 2 -1 HTML co de with te xt

My First HTML Poem

An HTML Poem

Roses are red ,
The Web is sure growing.
You can use HTML,
To keep your page flowing.



Figure 2-4 A mo re co mple te fo rmatte d We b page with te xt and a graphic image.

Part I — Friday Evening Session 2

28

Friday Evening

So me HTML tags, such as and , appear in Listing 2- 1, and yo u haven’t mastered them yet. Yo u will learn all abo ut Listing 2- 1’s HTML tags and many mo re as yo u pro gress thro ugh this weekend co urse. Mo st are extremely simple; fo r example, tells the browser to draw a ho rizo ntal line acro ss the browser window.

Not e

The only pot ent ial problem you may have in underst anding List ing 2 - 1 is t he st range value in t he following t ag: . The value #FF0000 is an int ernal represent at ion for t he color red. As you’ll learn in Sat urday morning’s sessions, you can represent specif ic color values numerically.

The Browser Det ermines t he Language Whereas pro grammers use HTML to fo rmat text, as shown in the previo us example, the tag demo nstrates that HTML is no t simply used fo r that purpo se. The

tag do es no t fo rmat text o r even the Web page; instead, it determines the title that appears in the browser window’s title bar. The browser used by yo ur Web page’s user determines exactly the way that yo ur page appears. Many browsers do no t suppo rt the same HTML co de that o thers suppo rt. Altho ugh newer browsers often provide suppo rt fo r the latest HTML co mmand tags, the HTML language is evo lving, as yo u learned in the previo us sessio n. One of the ways that a new co mmand tag is added is by a browser co mpany. Fo r example, when Internet Explo rer arrived o n the scene, Micro soft enabled that browser to read HTML instructio ns that had never been written befo re because no browser was designed to suppo rt these new co mmands. Unlike o ther kinds of pro gramming languages, such as C++, no central co mmittee determines the next co mmand tag to add to the next versio n of HTML. Altho ugh a Web co nso rtium do es exist to maintain HTML standards, mo st new co mmand tags co me fro m Micro soft and Netscape, the develo pers of the two mo st widely used browsers o n the market to day.

Cross-Ref

The World Wide Web Consort ium, found at http://www.w3.org/, cont ains t he lat est informat ion relat ed t o new and upcoming addit ions you can expect t o see in HTML. These addit ions of t en appear because of a browser company adding command t ags t o it s browser’s f eat ure set .

The result of the above facts is that the appearance of yo ur Web page can vary when viewed o n different co mputers. Thro ugho ut this weekend co urse, design issues beco me extremely impo rtant when using HTML, and an understanding of how different browsers suppo rt different levels of HTML also beco mes critical. I pay

Session 2 — HTML for Web Page Creat ion

29

particular attentio n in the next sessio n to maintaining pro per design issues that enable yo u to create Web pages that lo o k go o d o n any browser that yo u may use HTML co de to pro duce extremely fresh and attentio n- grabbing Web pages.

Not e

Most of t he f igures in t his book are shot using I nt ernet Explorer because t hat ’s my primary I nt ernet browser, but when major HTML dif f erences exist bet ween browsers, you’ll be t he f irst t o know as you progress t hrough t he weekend.

REVI EW 쐌 Co mmand tags often appear in pairs, such as and . 쐌 All HTML co de requires the minimum co mmand tags and . 쐌 Co mmand tags can be uppercase o r lowercase, but a move is under way to standardize with lowercase.

쐌 Use a and co mmand tag pair to specify a title in yo ur Web page’s browser window.

쐌 Specify exactly where yo u want yo ur Web page’s lines to begin and end; the browser will no t break lines auto matically.

쐌 Many HTML co des fo rmat yo ur Web pages to lo o k go o d. 쐌 New HTML co mmands often co me abo ut when a new browser suppo rts them.

QUI Z YOURSELF 1.

What are the two filename extensio ns all HTML files must use? ( See “ Minimum HTML.” )

2.

Which pair of co mmand tags must enclo se all Web pages? ( See “ Minimum HTML.” )

3.

Which co mmand tags enclo se yo ur Web page’s header sectio n? ( See “Adding Fo rmatting Co mmand Tags.” )

4.

Which co mmand tags enclo se yo ur Web page’s bo dy? ( See “Adding Fo rmatting Co mmand Tags.” )

5.

Why do es the
tag no t need a matching end tag? ( See “ Break Tags.” )

6.

What is o ne of the ways that a new HTML co mmand tag gets created? ( See “ The Browser Determines the Language.” )

Part I — Friday Evening Session 2

to display yo ur page. Yo u will no t have to write to the lowest- co mmo n do minating

SESSI ON

3 Web Page Design

Session Checklist ✔ Learn how yo ur users’ enviro nments may differ ✔ Create Web sites with all users in mind ✔ Utilize HTML validating pro grams to o ptimize yo ur Web site ✔ Answer initial design questio ns ✔ Publish yo ur Web site ✔ Learn abo ut the available free ho sting services

I

n this sessio n, Web page design takes precedence over HTML co de because yo ur HTML co de will suffer if yo u do no t design yo ur site pro perly. This bo o k’s go al is to teach yo u HTML in a weekend, and to do that, no t a lo t of time can

be spent o n design. Other texts exist that do a superio r jo b of teaching Web page design. Nevertheless, yo u must understand early how yo ur site is viewed by different users o n different kinds of co mputers, and yo u must understand so me of the trade- offs asso ciated with pro per Web site design. At the end of this sessio n, yo u will learn the pro cedures required to publish yo ur Web site o n the Wo rld Wide Web and the available Web sites that provide free ho sting services.

32

Friday Evening

Considering Your Environment As yo u learned in the previo us sessio n, yo ur Web page lo o ks different o n different co mputers. Yo u must understand the technical design issues that await yo u as an HTML pro grammer. Even amo ng the same kinds of co mputers, different users have varying screen sizes. To make things even wo rse, if that’s po ssible, users with the same co mputers and the very same mo nito rs might set their mo nito rs to different reso lutio ns! Figure 3- 1, fo r example, shows a Web page displayed at 800 × 600

pixels of reso lutio n. Figure 3- 2 shows the same Web page displayed at 640 × 480. No tice how much less of the Web page the lower reso lutio n displays.

Figure 3-1

At 800 ×600, the We b page lo o ks co mple te.

Not e

Act ually, t he resolut ions 8 0 0 × 6 0 0 and 6 4 0 × 4 8 0 are misleading because t he user’s browsers consume much of t he screen because of t he menu, t oolbars, and st at us bar. A more realist ic design area, if you want t o hit virt ually every Web user in t he world, is only 5 8 0 × 3 1 5 on a Mac and 6 3 5 × 3 1 4 on a PC.

Session 3 — Web Page Design

33

Part I — Friday Evening Session 3

Figure 3-2

At 640 × 480, the We b page is missing so me co nte nt.

What ’s an HTML programmer t o do? The pro blem of yo ur varying Web audience is no t insurmo untable. Nevertheless, yo u must keep the majo rity of yo ur users in mind when yo u design a page. Given that yo u’ve stepped up to the challenge of beco ming an HTML pro grammer, yo u may have a mo re powerful co mputer than many of yo ur Web page’s users. In additio n, yo ur co mputer may be faster. Fo r example, if yo u have a DSL co nnectio n, yo u get spo iled and perhaps fo rget abo ut tho se go lden days of 28.8 mo dem access. Many peo ple live in areas witho ut the benefit of DSL, this autho r being o ne of them. Therefo re, yo u must co nsider no t o nly the reso lutio n of yo ur target audience, but also the speed at which the Web pages yo u create will lo ad.

Never

Never overest imat e t he pat ience of your Web audience. The longer your Web page t akes t o load, wit h high- resolut ion graphics and act ive cont ent , t he less likely someone is t o wait for t he loading t o f inish. I nst ead of wait ing, t hey will go t o anot her sit e.

Web sites are no t single pages; they are multi-paged. Once yo ur users click downward into yo ur site, yo u can mo re freely offer Web pages that require scro lling. Once yo u grab the user, subsequent pages might co ntain higher-reso lutio n images and mo re text. At so me po int, yo ur users will be willing to wait o r scro ll because they have delved into yo ur Web site to find co ntent. The first page, called the ho me page,

34

Friday Evening

is where yo u sho uld mo st co nscio usly co nsider the general-purpo se Web user’s screen size and page-lo ading time.

Tip

As you design your HTML pages, keep thinking t op-t o-bot t om and left -t o-right . The typical Web user’s eyes follow this pattern. Design primarily for the upper-left hand portion of the screen, and place the important material there because the upper-left is the area seen first and by all users of your page. Loading time and resolution determine how much of the rest of your page the user sees without having to scroll. The more scrolling a user has to do to see your page, the less likely that user is to stay on your page.

A world wit hout images In additio n to keeping yo ur audience’s reso lutio n and page- lo ading speed in mind, yo u must also co nsider that so me of yo ur audience views pages with graphics turned co mpletely off. Figure 3- 3 shows a screen that sho uld co ntain several graphic images, but graphic placeho lders are in their place. Web browsers offer the o ptio n to turn off the display of images ( unless the user clicks o n an image to trigger that image’s downlo ad and display) , and the slower the co nnectio n, the mo re likely a user is to turn off images so the pages lo ad quickly. As yo u design yo ur Web page, keep in mind that yo u sho uld display text aro und images to label clearly the image’s purpo se so text- o nly users will understand what yo ur page co ntains. A co nstant trade- off exists between speed, reso lutio n, and co ntent, and yo u’ll make trade- offs as yo u design every single element of yo ur Web page. Fo r example, yo u may design a super graphic image that yo u want placed in the backgro und of yo ur HTML page. Befo re placing that image, however, yo u’ll have to adjust the image’s reso lutio n to be as low as po ssible, while still maintaining as much of the image’s quality as yo u can. The trade- off can be painful, because greatlo o king images at high reso lutio n do no t always translate well to a lower reso lutio n. If yo u do n’t mind lo sing so me of yo ur audience, yo u may cho o se to display images at the higher reso lutio n. The impo rtant thing is no t setting the reso lutio n but being aware of the trade- offs and that so me users will give up o n yo ur page befo re the page has had a chance to lo ad co mpletely.

Not e

More and more Web sit es now make available several versions of t he same sit e. On t he sit e’s home page, hyperlinks may be available t hat t ake viewers t o a t ext - only page or a higher- resolut ion, graphics- orient ed page for users wit h fast er connect ions.

Session 3 — Web Page Design

35

Part I — Friday Evening Session 3

Figure 3-3 Graphic place ho lde rs o n the We b page indicate that the display of We b page image s is turne d off.

Validat ing Your Page All Web designers feel the trade- offs discussed in the previo us sessio n. Fo rtunately, to o ls exist that help yo u ho ne yo ur HTML co de so that yo ur site pro duces the maximum benefit given the afo rementio ned co nstraints. Yo ur site will lo ad quickly because yo u’ve taken the time to make yo ur site technically efficient. One of the many such to o ls available is called an HTML Validato r ( see http://www.html

validator.com/) , a pro duct yo u can purchase that offers suggestio ns o n improving yo ur site’s efficiency. AI Internet So lutio ns provides the HTML Validato r o n their HTML Validato r Web site that provides the best- known site advice pro ducts in the industry. Many Web designing pro grams, such as Dreamweaver, currently offer similar advice fo r yo ur Web page. The current versio ns of pro grams yo u might use to accent yo ur HTML creatio n, such as the Ado be Pho to Sho p and Micro soft Pho to Draw graphics pro grams, offer

36

Friday Evening

advice fo r creating images that wo rk well fo r the majo rity of users who may see yo ur site. Once yo u finish designing yo ur Web page, the validating ro utines fo und in these pro grams perfo rm actio ns such as:

쐌 Checking yo ur HTML co de and info rming yo u which browsers will have tro uble displaying the co de

쐌 Info rming yo u which graphic images will take to o lo ng to lo ad 쐌 Determining which co lo rs o n yo ur Web site are no nstandard 쐌 Lo cating mismatched start and end co mmand tags 쐌 Advising yo u o n alternative fo nts that might display mo re effectively As yo u pro gress thro ugh the rest of this weekend co urse, yo u’ll learn how to design aro und many co mmo n pro blems in HTML co ding. ( Fo r example, Saturday’s mo rning sessio ns will discuss which co lo rs are co nsidered We b safe, that is, displayable o n the majo rity of the browsers.) As yo u write mo re and mo re HTML co de, yo u’ll begin to spo t tro uble areas o n yo ur own and wo rk aro und them, but yo u’ll still find that these HTML validating pro grams are extremely useful fo r catching small pro blems yo u might miss. Altho ugh yo u may use a simple text edito r to create the bulk of yo ur Web page, an HTML validatio n pro gram such as HTML Validato r helps maximize yo ur design to the largest po ssible audience.

I nit ial Design Considerat ions Befo re setting o ut to create yo ur Web page, co nsider the fo llowing:

쐌 Who is yo ur audience? 쐌 What is yo ur message? Surely, these design questio ns are so o bvio us they can go witho ut being asked, right? Actually, no t o nly do they need to be asked, they also need to be asked befo re, during, and after a Web site is develo ped. Co nsider the technical design issues discussed in the previo us sectio ns. Suppo se yo u are designing a Web page that provides suppo rt fo r iMac users. Yo u wo uld no t want to limit yo urself by making yo ur Web page efficient fo r bo th Mac and PC users. The co lo rs available to the Mac user typically are mo re numero us than the co lo rs available to the PC user. Yo u wo uld be freer to use these additio nal co lo rs since yo ur site is geared specifically to the Mac.

Session 3 — Web Page Design

37

Session 8 describes proper color select ion.

In additio n to the technical design issues that yo u’ll master mo re fully as yo u pro gress thro ugh this weekend, yo ur site’s makeup of pages and how tho se pages co nnect determine the feel that yo u want yo ur site to co nvey. Altho ugh they are rare, so me Web sites are co mpletely co mprised of a single page. Many perso nal ho me pages that keep friends and family updated o n the latest info rmatio n of a family co nsist of a single page o r two that effectively co nvey all the info rmatio n needed. On the o ther hand, co rpo rate Web sites that include pro duct info rmatio n, o rdering, and co ntact info rmatio n might co nsist of a hundred o r mo re Web pages. Many Web sites have a central theme o r primary to pic that co nveys a message. If yo u canno t narrow yo ur site to a central theme, co nsider rethinking yo ur site and po ssibly dividing the site into two separate sites. Co nstantly match yo ur fo nts and graphic images with yo ur to pic as well. Fo r example, if yo u want to po rtray a friendly, no nco rpo rate feel, use fo nts that co nvey less of a fo rmal, business feeling and that add mo re of a fun flair to yo ur site.

Tip

Once you’ve decided on your primary t opic, keep focused on t hat t opic. Once you’ve creat ed some Web pages, t est whet her or not your pages f it your t opic by asking ot hers t o view t he pages and see how close t hey can come t o det ermining your primary t opic and t he overall goal of t he sit e.

Web st ruct ures HTML pro grammers structure Web sites differently because the go als of Web sites differ greatly. As yo u’ve seen in this sessio n, the audience and the primary to pic determines the lo o k and feel of the site. Generally, Web sites fall into o ne of these three catego ries:



Se que ntial o r Line ar: Each page in the site is just a co ntinuatio n of the

preceding page. The ho me page o r start page is simply the first page in the sequential link of pages. Sites that are based o n the sequential structure often are reading sites that tell a specific sto ry o r that need to teach the user a subject in a specific o rder.

Part I — Friday Evening Session 3

Cross-Ref

38

Friday Evening

Hie rarchical: The ho me page is co nsidered to be the to p of the Web site,



with subsequent pages branching o ut fro m the ho me page. The hierarchical site is the mo st co mmo n site, often being used fo r bo th co rpo rate and perso nal pages, with the ho me page being the launch pad fo r the rest of the site’s areas. We b: Pages are linked as needed, but no single page, including the ho me



page, has prio rity over the o ther pages. When a site co ntains data that do es no t fall in a specific preset o rder, the Web structure is used to give the user several avenues of branching amo ng the pages. An invento ry system designed fo r a co rpo rate intranet wo uld make a go o d candidate fo r this structure. Figure 3- 4 shows the three structures that Web designers use to determine the lo gical o rder fo r users to navigate a site. So me Web sites provide areas that co ntain mo re than o ne structure. Yo ur site’s message determines the site’s structure.

The Web page design walkt hrough No text o n Web page creatio n wo uld be co mplete witho ut the typical steps an HTML co der takes to design the page. That list fo llows, but unlike many tasks in co mputer pro gramming, Web page design is no t a pro cedural task. A Web page is never finished. The elements o n yo ur Web page to day pro bably will change to mo rrow and will be co mpletely different in a mo nth of two . Fo llowing are the steps yo u fo llow when yo u first design yo ur site, but yo u’ll be returning to them, in a different o rder, as yo ur site evo lves. To design yo ur Web page, yo u will:

1.

Determine yo ur site’s theme and primary to pic o r task.

2.

Determine the structure that best suits the site.

3.

Sketch yo ur site’s ho me page to begin wo rking o n the to ne of the entire site; yo ur ho me page sets the standard fo rmat fo r the rest of the site.

4.

Co llect the text and graphic images that will appear o n the site.

5.

Create the initial page and blo ck o ut the areas co nsumed by the headings, sidebars, menus, fo o ters, and bo dy of the page.

6.

Enter the text and add the images to their appro priate lo catio ns.

7.

Add hyperlinks to and fro m o ther pages yo u will be creating, as well as to o ther reso urces o n the Internet yo u want to link to .

8.

Publish yo ur Web page.

39

Session 3 — Web Page Design

Sequent ial Page St ruct ure Home Page

Home Page

Web Page St ruct ure Home

Figure 3-4 The thre e co mmo n We b site structure s de te rmine how use rs navigate We b site s.

In additio n to being an o ngo ing pro cess versus a straight, sequential o rder of steps, several of the Web page creatio n steps require a surprising amo unt of wo rk. Fo r example, co llecting graphic images entails lo cating images yo u can use, creating yo ur own images fro m a so urce such as a scanner, digital camera, o r drawing pro gram, and wo rking tho se images so that their co lo rs and reso lutio n wo rk well in the majo rity of browser windows that will display yo ur site.

Sat urday morning’s sessions on graphics will explain more about opt imum colors and image resolut ion. Cross-Ref

Part I — Friday Evening Session 3

Hierarchical Page St ruct ure

40

Friday Evening

Tip

Once you begin t o creat e Web pages, you will f ind yourself crit iquing ot her Web sit es. Such crit ique is good. You learn by wat ching how ot hers creat e Web sit es. Most Web browsers enable you t o view t he HTML source code used t o creat e t hat sit e. ( You can do t his by select ing View ➪ Source or a similar opt ion t hat usually appears on Web browser menus.)

Yo u will learn many Web design techniques by studying HTML co de fo r the sites that yo u like. Do n’t steal the co de, however, but learn what the HTML co der used to pro duce the site and experiment with yo ur own styles that yo u gleam fro m o ther sites alo ng the way.

Publishing Web Pages Knowing HTML do es no t get yo ur Web site published, o nly created. Yo u must have an avenue to get yo ur Web page o n the official Internet set of pages, and that means getting a Web address ( called a URL fo r Unifo rm Re so urce Lo cato r) assigned to yo ur site. Once yo u create yo ur site, yo u need to do the fo llowing to publish yo ur Web pages:

1.

Determine a do main name, the po rtio n of the Web address that appears befo re the .com, such as myNewPage in http://www.myNewPage.com; that do main name must be unused by anyo ne else.

2.

Register yo ur do main name. By registering, yo u find o ut if yo ur do main name exists, and, if no t, yo u pay to own that do main name fo r a specific perio d of time. The co st typically runs fro m $100 to $150 fo r a three- year registratio n.

3.

Lo cate and register with a We b ho st, a co mpany that uses its co mputers to serve up yo ur Web pages 24 ho urs a day to the Internet. Many Web ho sts also verify whether o r no t yo ur do main name is already in use, and if no t, will register the do main fo r yo u so that yo u can use a Web ho st at the same lo catio n. Altho ugh yo u can use yo ur own co mputer as a server to the Internet, yo u’re typically better off hiring the services of a ho st because a ho st can provide backup services, generally has equipment required fo r high- capacity Web page visits, and utilizes redundant sto rage techno lo gy to ensure that the site stays up. Free Web ho sting services are also available. These are discussed in the next sectio n.

Session 3 — Web Page Design

4.

41

Publish yo ur Web pages by uplo ading yo ur HTML co de and images to the ho st’s site. Generally, the ho st will tell yo u exactly how to go abo ut pub( fo r File Transfe r Pro to co l) to transfer the site fro m yo ur co mputer to the ho st, but many ho sts have their own special requirements.

5.

Test yo ur site by traversing all pages and hyperlinks, making sure that the site perfo rms to yo ur satisfactio n.

Available Free Host s Many Web sites, mo st no tably the po rtals such as Yaho o ! and Geo cities, offer Web ho sting services fo r free. Yo u can register at these sites fo r Web ho sting space and uplo ad yo ur images and HTML co de directly to their servers fo r instant ( and free) Web pages.

Not e

Many of t he f ree Web host ing services display banners and popup window advert isement s on t op of your Web page when users visit your home page. I n addit ion, you are limit ed t o t he domain name t hat you can use. Generally, your sit e ’s name will be prefaced wit h t he Web host sit e ’s name, such as http://www. geocities.com/mysite.html. I n t his URL, geocities represent s t he Geocit ies Web sit e.

These sites are perfect fo r experimenting and learning HTML, as well as fo r designing yo ur early Web pages. Instead of paying fo r professio nal Web ho sting services, yo u can place yo ur initial Web page designs o n these free Web ho sts and make sure the pages perfo rm as yo u expect. So me of the free Web ho sts are:

쐌 Geo cities ( http://www.geocities.com/) 쐌 Yaho o ! ( http://www.yahoo.com/) 쐌 Micro soft Netwo rk ( http://www.msn.com/) 쐌 America Online ( http://www.aol.com/)

Part I — Friday Evening Session 3

lishing o n that specific ho st machine. Yo u might use a pro gram called FTP

42

Friday Evening

REVI EW 쐌 Design Web pages so that yo ur users can see the mo st info rmatio n po ssible. 쐌 The speed of yo ur user’s co nnectio n and their screen reso lutio ns affect the lo ading and display of yo ur Web page.

쐌 The faster yo ur pages lo ad, the mo re likely users are to stay at yo ur Web site. 쐌 An HTML Validato r will info rm yo u of tro uble spo ts o n yo ur Web pages. 쐌 Design and maintain yo ur Web site with yo ur audience and target to pic in mind.

쐌 A Web ho st will register yo ur Web site’s do main name and act as a server fo r yo ur Web site.

QUI Z YOURSELF 1.

Which reso lutio n displays the mo st info rmatio n: 640 ×480 o r 800 ×600? ( See “ Co nsidering Yo ur Enviro nment.” )

2.

Which co rner of the screen sho uld ho ld the mo st impo rtant links and site info rmatio n? ( See “ What’s an HTML Pro grammer To Do ?” )

3.

How do so me Web users eliminate the slow lo ading speed of images? ( See “A Wo rld witho ut Images.” )

4.

True o r False: Yo u canno t view o ther Web sites’ HTML so urce co de because the co de is secured with passwo rds. ( See “ The Web Page Design Walkthro ugh.” )

5.

What is the jo b of the Web ho st? ( See “ Publishing Web Pages.” )

SESSI ON

4 Maint aining and I mproving Your Web Sit e

Session Checklist ✔ Pro perly maintain yo ur Web site ✔ Optimize the o rganizatio n of yo ur co mputer’s files and fo lders ✔ Test and maintain yo ur Web site o n yo ur own lo cal Web server ✔ Allow yo ur Web site to reflect the ever- changing HTML ✔ Learn abo ut Web pro gramming to o ls to accent yo ur HTML co de

ne of the primary jo bs of the HTML pro grammer that yo u sho uld learn is

O

pro per site management. The cho ices yo u make when yo u first design a Web site, such as cho o sing pro per fo lders o n yo ur own co mputer in which yo u

sto re the site’s files, can help o r hamper yo ur jo b later as yo ur site grows. In additio n to managing a site pro perly, yo u need to stay abreast of the to o ls and new techno lo gies available to help yo u improve yo ur Web site. This sessio n explo res so me of the HTML to o ls and o ther Web page languages that have beco me available that yo u can implement alo ng with yo ur HTML pages.

44

Friday Evening

Success Means Const ant Web Sit e Maint enance Keep yo ur Web site fresh if yo u want users to return. When so meo ne begins to create a Web site, they have little understanding as to how invo lved and timeco nsuming even simple Web sites beco me. Even small changes to a single Web page often require that yo u perfo rm these steps:

쐌 Downlo ad the Web page to edit to yo ur co mputer. 쐌 Make the change. 쐌 Uplo ad the changed page. 쐌 Test and review the page to ensure that the change wo rks. The final step, testing, may require that yo u wo rk o n the page mo re than o nce. Often, when yo u make a change, o ther parts of yo ur site are affected. Perhaps a hyperlink to an o bject o n yo ur page changes, o r perhaps yo u replace a figure that is still referenced fro m ano ther page o n yo ur site. Altho ugh HTML validating pro grams may help yo u lo cate these missing links, o ther unexpected pro blems can arise. Yo u sho uld view yo ur site in as many browsers and o n as many different kinds of co mputers as po ssible to ensure that yo ur site lo o ks go o d in vario us co nfiguratio ns. The bo tto m line is that yo u sho uld co nsider Web maintenance to be a jo b that always takes lo nger than yo u expect but is required fo r a site to be successful. Think of the Web sites that yo u often visit. Tho se sites no t o nly provide info rmatio n yo u need, but they also stay fresh and keep yo ur interest piqued.

Not e

I f you work f rom a modem or an int egrat ed services digit al net work ( I SDN) connect ion, t his process is even more t imeconsuming considering t he slow speed at which you must upload and download t he pages you are edit ing.

The testing stage needs to include the same pro ofreading as printed do cuments require. Read yo ur changes carefully to make sure the grammar and spelling are co rrect. Slo ppy HTML pro grammers use slo ppy spelling and po o r grammar.

The Best Way t o Organize Your Files and Folders No t o nly must yo ur Web site appear o rganized to yo ur users, but also yo u must o rganize yo ur own co mputer’s files that co ntain a wo rking co py of yo ur Web site. Create a new fo lder fo r each Web site yo u want to pro duce. The fo lder that yo u create is the

Session 4 — Maint aining and I mproving Your Web Sit e

45

Web site’s primary fo lder. Next, inside each Web site’s primary fo lder, create a subfo lder named image s where yo u place every image fo r that site. By do ing so , yo u the user’s browser will o nly need to lo ad the image o ne time if yo u place that image in yo ur images fo lder and reference that fo lder in yo ur HTML page. In additio n, yo u will no t have to deal with extended paths to images when they all reside in the same fo lder. If yo u change an image in the fo lder, all hyperlink references to that image will no t have to change.

Never

Never put mult iple versions of your Web page in t he same primary folder. For example, if you have four separat e versions of your Web page for four foreign languages, keep each of t hose versions in t heir own primary folder wit h t heir own images folder. Alt hough doing so means t hat you might be maint aining four separat e versions of t he same images, you event ually save t ime wit h simpler hyperlinks t hroughout your sit es.

Despite seeming as tho ugh yo u’re stuck in the Dark Ages, try to limit yo urself to the o ld DOS standard of 8.3 filenames, using htm as the filename extensio n unless yo ur HTML edito r suppo rts the html filename extensio n. Mo st of to day’s co mputers reco gnize mo re characters, but yo u’ll ensure that pro blems wo n’t arise with legacy browsers and Web ho sting software that yo u may still run into . In the wo rld of co mputers, go o d do cumentatio n is vital, and 8.3- character filenames certainly do no t allow extended self- do cumentatio n of filenames. However, fo r a few mo re years, such filenames are pro bably the safest to use.

Should You Turn Your Comput er int o a Local Web Server? If yo u wo rk fro m ho me, o r fro m a small business that do es no t provide fo r a 24- ho ur Web server, yo u have the o ptio n of turning yo ur co mputer into a lo cal server. The drawbacks are that yo u must keep the server active at all times, day and night, co nnected to the o utside wo rld so mehow. If yo u are linked to the Internet with a mo dem o r ISDN line, yo u do no t have the power to serve up multiple Web pages at o nce, if yo ur site receives traffic that warrants the serving of mo re than o ne page simultaneo usly. Despite its drawbacks, however, there is o ne benefit fro m turning yo ur co mputer into a server: With yo ur own lo cal server, yo u can accurately test yo ur site because yo u can create, edit, and maintain yo ur entire Web site o n yo ur lo cal server. Yo u wo n’t waste time uplo ading yo ur changes o nly to find that yo u must make additio nal co rrectio ns to fix a bro ken link o r o ther erro r befo re uplo ading the pages

Part I — Friday Evening Session 4

head off pro blems that may arise. If yo u use an image mo re than o nce, fo r example,

46

Friday Evening

o nce again. Instead, yo u’ll perfo rm all testing and editing o n yo ur own server, co rrecting mistakes there. Then, o nce the site is exactly the way yo u want it, yo u can uplo ad the site to a mo re powerful, full- time server o n yo ur Web ho st’s system.

Most PC operat ing syst ems, including Windows 9 8 , allow users t o creat e t heir own local Web server. Not e

The Ever-Changing HTML Yo ur jo b of learning HTML will cease o nly if so mething replaces HTML o n the Web. As discussed in Sessio n 2, new co mmand tags are intro duced with virtually every new browser that appears. In additio n, new techniques fo r using current HTML co mmands co ntinue to evo lve to help yo u maintain and create elegant, fast, attentio n- grabbing Web sites. Stay abreast of new browser features when they are released by visiting the manufacturer’s Web site to learn the new co mmands. Yo u can inco rpo rate these changes as yo u update yo ur Web site. Many Web sites exist that act as reso urces fo r yo u, the HTML pro grammer. The fo llowing Web sites are useful because they no t o nly co ntain design tips, but they also co ntain HTML co de samples and tuto rials that keep yo u up- to - date o n the latest HTML versio ns:

쐌 WebMo nkey ( http://hotwired.lycos.com/webmonkey/) : Provides expert HTML and design tips

쐌 HTML Reference Page ( http://hotwired.lycos.com/webmonkey/ reference/html_cheatsheet/index.html) : Provides an HTML cheat sheet

쐌 Experts Exchange ( http://www.experts-exchange.com/) : Answers to pro blems yo u might be having with yo ur HTML co de

쐌 iSyndicate ( http://www.isyndicate.com/) : Provides co ntent yo u can use o n yo ur site

쐌 CAIM Web Style Guide ( http://info.med.yale.edu/caim/manual/index. html/) : Provides standard guidelines to help yo u create an acceptable Web site with all the co mmo n elements Take a few mo ments o ut of yo ur weekend crash co urse to lo o k at these sites now so yo u’ll understand the kinds of reso urces that yo u and o ther HTML pro grammers can rely o n to bring the latest Web creatio n help to yo ur screen. Sites such as

Session 4 — Maint aining and I mproving Your Web Sit e

47

WebMo nkey provide expert advice and co lumns that they update regularly to keep yo u info rmed. As yo u create and edit yo ur site, yo u will enjoy the invaluable help

HTML and Company As yo u wo rk with HTML, yo u will think of elements ( fo r example, text, graphics, applets, o bjects, and Excel spreadsheets) yo u want to add to yo ur Web site that HTML simply canno t handle. HTML is o nly the first to o l in the HTML pro grammer’s bag of tricks. Altho ugh yo u have cho sen this weekend to learn HTML, yo u need to know what else is in sto re fo r yo u o nce yo u master HTML because if yo u do no t, yo u’ll be frustrated over HTML’s seeming lack of features. The reality is, HTML is extremely powerful and do es its jo b above and beyo nd the call of duty. Nevertheless, yo u need to understand the to o ls that interact with yo ur HTML co de so that yo u will better understand how active Web pages wo rk and yo u’ll know what yo u will be able to use later to improve and maintain yo ur sites.

DHTML DHTML is known as Dynamic HTML. DHTML actually do esn’t exist as its own lan-

guage, but it describes a set of to o ls that browsers might suppo rt that activate sites by enabling tho se sites to respo nd to actio ns perfo rmed by the users. DHTML includes suppo rt fo r the fo llowing items with which yo u sho uld begin to familiarize yo urself:



CSS, o r cascading style she e ts: With CSS, yo u can design yo ur own fo rmat-

ting co mmand tags to facilitate easier and mo re co nsistent Web site fo rmatting than with HTML alo ne. Several versio ns of CSS have been released. Mo st no tably, CSS Le ve l 1 ( CSS 1) allows yo u to define new fo rmats fo r yo ur Web pages much like Micro soft Wo rd style sheets do , and CSS-P, o r cascading style she e ts-po sitio ning ( also known as CSS 2) , enables yo u to specify

exact po sitio ns fo r text, graphics, and o ther HTML Web page elements.



JavaScript: This is an interactive pro gramming language, much like the C++

pro gramming language, which enables yo u to embed small pro grams called apple ts into yo ur HTML co de.

Internet Explo rer 3.0 was the first browser to intro duce the DHTML co ncept by offering CSS Level 1 co mmand tags, and o ther browsers pro mptly fo llowed. Currently, all releases of all majo r browsers suppo rt CSS, CSS-P, and JavaScript, but when yo u

Part I — Friday Evening Session 4

these suppo rt sites can provide.

48

Friday Evening

design yo ur sites, yo u must keep in mind that no t all Web users have the latest browsers. If yo ur page co ntains DHTML but so meo ne views yo ur page with an o lder browser, many of the active elements o n yo ur page may no t wo rk pro perly. Beginning in Sessio n 19, yo u will begin learning so me of these DHTML co ncepts in detail. Yo u do n’t have to be an advanced JavaScript pro grammer to take advantage of JavaScript and o ther DHTML elements in yo ur Web sites. Fo r example, yo u can pro duce ro llove r e ffe cts, shown in Figure 4- 1, which change butto ns o n yo ur Web page into o ther items ( such as different co lo rs that appear as the user po ints to butto ns with the mo use, o r perhaps butto ns that turn into dro p- down menus) as the user moves the mo use po inter over tho se butto ns. Yo u can do this by adding so me cut- and- paste JavaScript co de that yo u’ll find in later sessio ns to yo ur HTML pages.

The rollover ef f ect

Figure 4-1 JavaScript e nable s the butto ns o n yo ur We b page to change as the mo use po inte r is move d ove r the m.

Session 4 — Maint aining and I mproving Your Web Sit e

49

XML

language, to HTML and DHTML. XML go es beyo nd HTML to describe any kind of data file and provides database suppo rt. Pro grams that suppo rt XML, such as Micro soft Wo rd, can interpret XML co mmand tags that lo o k and act a lo t like HTML tags. Browsers that do no t suppo rt XML will igno re the XML tags.

Not e

Generally, browsers are programmed t o ignore t ags t hat t hey do not recognize as opposed t o displaying an error message. Therefore, t he browser you obt ain t oday will run t omorrow’s Web pages wit h HTML, XML, and just about any ot her t ag- based language even t hough t he browser may not execut e t he commands request ed inside t hose unknown t ags.

XML suppo rts CSS and all of the DHTML co mmands. Actually, XML is a superset of DHTML. The e xte nsible in XML, however, go es far beyo nd HTML o r DHTML. With XML, yo u literally can create yo ur own markup language. The language can clo sely match yo ur site’s design. Fo r example, if yo ur site sells bread, yo u can create an XML tag that is called BreadSpecial that yo u use fo r the special of the day. The weekend is no t nearly lo ng eno ugh to tackle HTML, DHTML, and XML. Fo rtunately, if yo ur go al is to develo p exciting Web pages, XML is no t a language yo u will need to wo rry abo ut fo r so me time unless yo u need to embed external data such as a Micro soft Excel spreadsheet inside yo ur Web pages. ( Excel saves its Web- based spreadsheets in the XML fo rmat.) Even then, Excel will handle all the XML, and yo ur jo b is o nly to lo cate a browser that can display XML in additio n to HTML. XML’s benefits co me in handy o nce yo u’ve mastered HTML and envisio n extending HTML to match yo ur site’s go als mo re clo sely using XML.

Act iveX cont rols Micro soft’s versio n of Java, ActiveX, offers a way to embed pro grammable o bjects, such as input fields. These special co ntro ls respo nd to the user’s events when using the co ntro l, such as clicking the co ntro l’s panel. One of the drawbacks of ActiveX co ntro ls is that when yo u design the co ntro l, yo u must co mpile the co ntro l o n every type of co mputer that will use the co ntro l. The advantage of ActiveX, however, is its cro ss- platfo rm abilities acro ss vario us co mpany to o ls. A Visual Basic pro grammer can create an ActiveX co ntro l, and an HTML pro grammer can embed that co ntro l o n the server’s site fo r distributio n alo ng with Web pages.

Part I — Friday Evening Session 4

XML means e xte nsible Markup Language and provides a so rt of extensio n, o r superset

50

Friday Evening

CGI Many co mmercial Web sites co ntain CGI, o r Co mmo n Gate way Inte rface, co de. CGI is no t a language but a scripting service by which the server of the Web page co ntains co de written in a pro cedural Web language, such as Pe rl. The server executes the co de when the user of the Web page triggers the co de, as might happen when the user clicks a butto n to place an o nline o rder. The CGI co de do es no t appear in the HTML co de and is no t visible to the user.

ASP ASP stands fo r Active Se rve r Page s and represents se rve r-side pro gramming, a fancy

term fo r the pro grams that run o n the Web ho st’s machine as o ppo sed to pro grams that run o n the user’s co mputer. To utilize ASP, yo ur Web ho st must utilize Micro soft Web server extensio ns. No t unlike CGI and o ther scripting languages, ASP runs o n the server’s co mputer, but the results appear o n the user’s Web page. ASP uses the DLL, o r Dynamic Link Library, co ncept so that o nly o ne co py of an executable ro u-

tine has to be in memo ry at o ne time, saving o n reso urces.

Not e

Not every language and script ing service available t o t he HTML programmer is discussed here because of t ime limit at ions of t he weekend. For example, VBScript and Java are languages t hat an HTML programmer can use t o accent a Web page.

REVI EW 쐌 A co nstant maintenance of yo ur site, altho ugh necessary, is a timeco nsuming jo b that tends to take lo nger than expected.

쐌 Pro ofread yo ur Web site to keep a professio nal appearance and to ensure that the site wo rks well.

쐌 Sto re yo ur Web site in its own fo lder fo r simple access to yo ur files. 쐌 Co nsider running a Web server fro m yo ur own co mputer if yo u want maximum co ntro l over yo ur site.

쐌 If yo u want to activate yo ur Web site, use DHTML. 쐌 HTML pro grammers can use several scripting languages to add custo m and secure features, such as electro nic co mmerce, to a Web site.

Session 4 — Maint aining and I mproving Your Web Sit e

51

QUI Z YOURSELF What pro blems can o ccur when yo u make changes to yo ur site? ( See “ Success Means Co nstant Web Site Maintenance.” )

2.

Which fo lder sho uld ho ld yo ur site’s images? ( See “ The Best Way to Organize Yo ur Files and Fo lders.” )

3.

What are so me drawbacks to using yo ur own perso nal Web server? ( See “ Sho uld Yo u Turn Yo ur Co mputer into a Lo cal Web Server?” )

4.

True o r False: Windows 98 users canno t turn their co mputers into Web servers. ( See “ Sho uld Yo u Turn Yo ur Co mputer into a Lo cal Web Server?” )

5.

What do cascading style sheets acco mplish? ( See “ DHTML.” )

Part I — Friday Evening Session 4

1.

SESSI ON

5 Text on Your HTML Page

Session Checklist ✔ Make text the centerpiece of yo ur site ✔ Create a template fo r yo ur Web pages ✔ Master fo nt selectio n and learn new tips fo r adding them ✔ Learn the co mmo n text- fo rmatting co mmand tags

his mo rning yo u will begin to learn specific mechanics of HTML co ding. The

T

co rnersto ne of any Web page is the text. Altho ugh yo ur graphics accent the text message yo u want to co nvey, the text co ntains the detailed info rmatio n

yo ur users want to know abo ut. With HTML, yo ur Web page can co ntain mo re text- fo rmatting co mmand tags than ever befo re. Mo st browsers in use to day suppo rt all of the text tags that yo u’ll learn in this sessio n.

58

Sat urday Morning

Text I s t he Foundat ion The text that yo u put o n yo ur Web site speaks to the wo rld. As mentio ned in Sessio n 4 of last night’s sessio ns, yo u’ll want to pro ofread yo ur Web page to ensure that yo u’ve used pro per grammar and co rrect spelling. The text that yo u display is a reflectio n o n yo u, the autho r of the Web page.

Tip

Never

I f your site contains written articles and columns, consider writing them using a word processor with a grammar and spelling checker. Then save the article as a text file, with a txt filename extension, and import it into your HTML code from within the text editor. Save the file with the htm or html extension if your word processor saves directly in the HTML format. I f, instead, you type the text directly in your HTML editing program as you write the HTML, the command tags will get in the way and you won’t have the benefit of spelling and grammar checking. Never forget your goal: t he Web page’s informat ion, not t he HTML code t hat you writ e t o produce t hat informat ion. Concent rat e on accuracy and well- f lowing t ext . The t ext must work on it s own before it works inside your HTML code.

Depending o n yo ur Web site’s go als, yo u will need to decide the o ptimum amo unt of text to display at any o ne time. Generally, yo u’ll want to keep yo ur ho me page sho rt o n text ( as well as graphics that will co nsume lo ading time) . Co nsider the IDG ho me page shown in Figure 5- 1. By keeping the text sho rt and placing the o pening text snippets o n the ho me page, the user can glance at the overall Web site and select the exact info rmatio n desired.

Your Web Page General Layout Templat e Figure 5- 2 shows a general mo del fo r the layo ut of all HTML co de. Web pages often co ntain the fo llowing sectio ns:

쐌 Header 쐌 Title 쐌 Bo dy 쐌 Fo o ter

59

Session 5 — Text on Your HTML Page

Clicking here displays more t ext

Part I I — Sat urday Morning Session 5

Figure 5-1 Ke e p te xt to a minimum o n yo ur We b site ’s ho me page.

In Sessio n 2 of last night’s sessio ns, yo u learned so me of the co mmand tags that pro duce these Web page sectio ns. The fo o ter sectio n is new to yo u, but as yo u can guess, the fo o ter appears at the bo tto m of yo ur Web page just as the header sectio n starts yo ur Web page. Fo o ters often co ntain co ntact info rmatio n and perhaps a navigatio nal bar that links the Web page user to o ther pages o n the site. No fo rmal fo o ter tags exist; nevertheless, mo st Web pages have an o bvio us fo o ter sectio n that helps terminate the info rmatio n o n the page. One of the ways to ensure that yo ur Web pages co ntain all the impo rtant elements is to create a te mplate that co ntains a Web page’s bare- bo nes layo ut to help yo u structure the text o n yo ur Web page. Listing 5- 1 shows o ne such template. Yo u can sto re this template o n yo ur hard disk, perhaps under the name Template.html, and then lo ad the template and save it under a new filename when yo u create subsequent Web pages.

60

Sat urday Morning

Header sect ion



Body of Web page

Foot er Sect ion



Figure 5-2 Virtually all We b page s fo llow this ge ne ral layo ut.

Listing 5 -1 A te mplate to he lp yo u lay o ut yo ur We b page

Window title goes here

Session 5 — Text on Your HTML Page

61

The body of the Web page, text and graphics, appears here



in the go o d habit now of using

. The paragraph tag fo rces a blank line o n the screen that shows the beginning of paragraphs — in effect, inserting a do ublecarriage return fo r each

.

The ot her t ags in List ing 5 - 1 are explained in Session 2 .

Cross-Ref

If yo u create yo ur initial Web page with a Web page designing to o l, such as Dreamweaver o r Fro ntPage, the pro gram will handle writing the basic tags in yo ur template as yo u build the page. Once yo u have the basic page designed, yo u can then edit the HTML co de to make the page lo o k exactly the way yo u desire.

Tip

The Yale C/ AI M Web St yle Guide sit e ( htttp://info.med. yale.edu/caim/manual/index.html/) out lines a Web st yle guideline t hat ensures t hat your sit e follows an accept able, st andard layout . Of course, t he Web’s beaut y is t hat your sit e doesn’t have t o conform t o all t he ot hers. Nevert heless, general design principles span all Web pages, and as a newcomer t o HTML, you will gain design and layout insight s as you scan t his sit e.

Dealing wit h Specific Font Limit at ions As yo u already learned, all text that appears between the and tags appears o n the browser’s screen. Witho ut line o r paragraph breaks, the text do es no t appear o n separate lines, and witho ut text-fo rmatting tags that might italicize o r bo ldface wo rds and phrases, the text appears in the browser’s default fo nt.

Part I I — Sat urday Morning Session 5

The

and

tags begin and end paragraphs. Actually, the end tag,

, is o ptio nal, but future HTML versio ns may require the paragraph’s end tag, so get

62

Sat urday Morning

The mo st co mmo nly used fo nt fo r the Mac is Helvetica. The mo st co mmo nly used fo nt fo r PC- based systems is Arial. Bo th fo nts are sans se rif fo nts ( sans means witho ut in Latin) ; that is, they co ntain straight lines and circles witho ut any extra

bubbles, lines, o r curves to the characters. Sans serif fo nts require less reso lutio n than serif- based fo nts and, as a result, are mo re readable o n Web screens. The extra reso lutio n necessary to display serif fo nts generally is no t available to o rdinary text o n the Web browser’s screen because the reso lutio n fo r each character is to o narrow. Figure 5- 3 demo nstrates this. The mo re readable letter a ( o n the left side of the figure) is in a sans serif fo nt; the letter a o n the right is a serif- based fo nt, Times New Ro man ( which is the same as the Mac’s Times fo nt) .

Figure 5-3 Sans se rif fo nts, like the o ne o n the le ft, are mo re re adable o n We b scre e ns.

In additio n, yo u will no t be able to determine which fo nts are available o n yo ur Web page’s user’s co mputer. Fo r example, altho ugh yo u may have the latest versio n of a fo nt called Humo ro usGo thic, chances are that users viewing yo ur Web pages wo n’t have Humo ro usGo thic. Generally, yo u’ll need to keep yo ur fo nts simple and attempt to use fo nts available to all Web page users.

Specifying a font If yo u want to specify a fo nt, use the and co mmand tag pair. The attribute face= determines the fo nt ( technically, the type face ) that yo u request fo r yo ur Web page’s text. The fo rmat is as fo llows:

Yo u can co ntro l the fo nt used fo r individual characters, wo rds, sentences, paragraphs, o r co mplete Web pages depending o n what falls between the

Session 5 — Text on Your HTML Page

63

start and ending tags. ( A few metho ds fo r co ntro lling the fo nt with the tags are discussed in the fo llowing sectio ns.) Again, yo u must remember that yo ur users wo rk o n different systems and that special, unusual fo nts are risky. If the target browser do es no t suppo rt the fo nt yo u specify in the tag, the browser will substitute a different fo nt and the resulting fo nt will no t always be clo se to what yo u requested.

Alternating fo nts in yo ur co de can help yo u determine which fo nts are easier to read by the browser. The fo llowing HTML co de alternates between Arial and Times New Ro man fo nts o n each line displayed:

Italy ice cream,

called gelato,

is the richest, creamiest ice cream in the world.

Buon Apitito!

Figure 5- 4 shows these co de lines inside the browser. The Times New Ro man fo nt, a serif fo nt, is smaller and mo re difficult to read o n co mputer screens than the Arial fo nt.

Figure 5-4 Alte rnating fo nts de mo nstrate which style s are e asie r to re ad o n the mo nito r.

Part I I — Sat urday Morning Session 5

Alt ernat ing Bet ween Font s

64

Sat urday Morning

Specifying Mult iple Font Names No tice that the tag accepts o ne o r mo re fo nt names. If yo u specify multiple fo nts, separated by co mmas, enclo se the list between quo tatio n marks. The target browser begins at the leftmo st fo nt in the list and attempts to display the subsequent text in that fo nt. If the fo nt is unavailable, the browser picks the next fo nt in the list and go es down the line until the browser can match a fo nt o r has to use o ne of the default fo nts. The fo llowing tag requests that the subsequent text appear in the Century fo nt if available, then in the Scho o lbo o k fo nt if Century do esn’t exist o n the browser’s co mputer, and finally, Antique. If no ne of the three is available, the user’s browser selects the default fo nt.

Never enclose each font in the list inside its own pair of quotes. Always include the entire font list inside a single pair of quotation marks, as shown in the previous example. Never

Specifying Sans Serif and Serif Font s To ensure that yo u get a sans serif fo nt o n all systems, PCs, and Macs, yo u co uld use the fo llowing tag fo r sans serif fo nts:

The fo llowing tag wo rks fo r serif fo nts o n bo th PCs and Macs:

Tip

I nst ead of specif ying an exact font name, and risking t he t arget comput er subst it ut ing a dif f erent font , you can specif y serif , sans serif , or monospace for t he font name. The t arget browser will t hen use t he default font t hat f it s t hat descript ion. Monospaced font s display each charact er, f rom t he narrowest t o t he widest , using t he same column widt h so t hat all t he screen’s charact ers line up t oget her. The and t ypewrit er command t ag pair also displays t ext in monospaced format .

The next sessio n describes so me ways yo u can make new fo nts available to every system that views yo ur Web page.

Session 5 — Text on Your HTML Page

65

Graphic font s One of the best ways around the lack of fonts on target browsers is to use whatever font you prefer, no matter how rare or new that font is, and save the text as a graphics image in a program such as PhotoShop. The image will appear on your Web page exactly as you intend. Such textual images are great for banners and headlines whose font styles help to portray a certain image, such as flying serifs for an airline’s name.

The drawback to using a graphic image over using text is that the image will take much lo nger to lo ad than the text equivalent takes. In additio n, yo ur users wo n’t be able to highlight the text o n the screen and cut and paste the text as they can regular text. ( The user can, however, save the Web page image to disk as a graphic image.) The rules fo r creating graphics in general apply also to fo nt image files.

Sessions 6 and 7 cover t he use of images in your pages.

Cross-Ref

Format t ing Your Text wit h Command Tags Given the limitatio ns of available fo nts, yo u sho uld co ncentrate mo re o n making the standard available fo nts lo o k go o d. Yo u can effectively use text in yo ur Web pages by co ntro lling the size and style of yo ur text. Yo u can do this with the co mmo n text- fo rmatting co mmand tags.

Present able headlines A headline often appears befo re a bo dy of text and is larger than the bo dy to make it stand o ut. Users can glance thro ugh the headlines, as shown in Figure 5- 1, and select the articles that they want to view in mo re detail. HTML suppo rts a standard headline co mmand fo rmatting tag that virtually every Web page uses. The fo rmat fo r the headline tag is as fo llows:

Part I I — Sat urday Morning Session 5

In addition, you can accurately control spacing between characters ( called ke rning ) or between lines ( called le ading ) , which you cannot do in HTML.

66

Sat urday Morning

In this example, n ranges fro m 1 to 6, with 1 being the largest and 6 being the smallest fo nt. A co rrespo nding end tag terminates the headline size. Figure 5- 5 shows the result of the fo llowing co de that demo nstrates the six decrementally smaller headline tags:

This This This This This This

is is is is is is

headline headline headline headline headline headline

1’s 2’s 3’s 4’s 5’s 6’s

size size size size size size

Figure 5-5 The he adline tag give s yo u six de cre me ntally smalle r he adline size s.

The headline tags enable yo u to o rganize yo ur headlines in an o utline fo rmat so that yo ur to p headline can be the largest, and then as yo u use subheadlines, yo u can adjust the size down. Of co urse, HTML pro grammers rarely nest headlines mo re than three deep and virtually never use , , o r . No tice that the headline tags auto matically issue a line break at the end of the headline, so yo u do no t have to use
o r

tags. By default, browsers left- align and bo ldface headlines. In the next sessio n, yo u will learn how to align headlines and o ther text in the center o r in the Web page’s right margin.

67

Session 5 — Text on Your HTML Page

PCs display headlines slight ly larger t han t he same sized headlines on Macs because of t he dif f erent resolut ion used on t he t wo syst ems. Generally, t he dif f erence does not dest roy t he ef f ect s on your Web page, but t o be sure, you may want t o t est your pages on bot h syst ems if t he size of your headlines will negat ively af f ect your Web page layout .

Not e

Never

Font size Yo u can fo rmat no rmal text in a variety of sizes like yo ur headlines. The ’s

size= attribute co ntro ls the size of text. The fo rmat is as fo llows:

In this example, n ranges fro m 1 to 7. Unlike the headline tag, however, the lower the number the smalle r the fo nt size. This discrepancy is o ne of tho se issues that has been with HTML since the first versio n, and will remain until the last. As with many attributes, the number may o r may no t appear inside quo tatio n marks; the quo tes are o ptio nal. Figure 5- 6 shows the result of the fo llowing co de that demo nstrates the seven incrementally larger fo nt size tags:

This

is is is is is is is

font font font font font font font

size size size size size size size

1 2 3 4 5 6 7










The tag with the size=n attribute specifies the size of all text in yo ur do cument that is no t specified by a tag. In additio n to size, the

tag can specify co lo r and several o ther attributes.

Part I I — Sat urday Morning Session 5

Never use a headline t ag just because you want t o boldface and enlarge body t ext . Alt hough headline t ext is boldfaced by default , you’ll learn lat er in t his session how t o apply boldfacing t o specif ic t ext .

68

Sat urday Morning

Figure 5-6 The fo nt size tag give s yo u se ve n incre me ntally large r fo nt size s.

Not e

Session 2 0 t eaches you how t o writ e CSS, cascading st yle sheet s, which make many of t he individual t ext - format t ing t ags discussed here obsolet e. Familiarize yourself wit h t hese t ext - format t ing t ags because t ons of Web pages st ill use t hem. Of t en, t he individual t ags are used t o format specif ic areas of a page and a CSS is not def ined. I n addit ion, CSS is easier once you underst and t he individual format t ing t ags.

Charact er format t ing All the standard fo rmatting styles are available to yo u when writing HTML co de. Yo u can italicize, bo ldface, underline text, and mo re.

Not e

HTML programmers cringe when t hey see underlined t ext on a Web page. Generally, hypert ext links appear on t he screen as underlined t ext , and when underlining is used on nonhyperlinked t ext , users wast e browsing t ime at t empt ing t o click t he hyperlink t hat does not exist . Good design dict at es t hat you use it alics and t ypefaces t o emphasize t ext .

Use the and tag pair to indicate bo ldfaced text. The fo llowing HTML statement pro duces a bo ldfaced wo rd in the middle of a sentence:

This sentence contains one boldfaced word.

Session 5 — Text on Your HTML Page

69

No tice that yo u must include a space aro und the tags, just as yo u wo uld do if the

and tags did no t exist. The fo rmatting tags add no spacing to yo ur text. Use the and tag pair to indicate italicized text. The fo llowing HTML statement pro duces an italicized wo rd in the middle of a sentence:

This sentence contains one italicized word. If you must underline text, use the and command tag pair, as done here:

Use the and tag pair to create text with a strike thro ugh effect; fo r example, yo u might use strikethro ugh to cro ss o ut items no lo nger offered fo r sale. The fo llowing line strikes thro ugh two wo rds:

This sentence contains two words that use the strikethrough effect. Mathematical equatio ns often require subscript te xt ( text that falls below the no rmal text baseline) and supe rscript te xt ( text that appears above the no rmal text baseline) . Use the and tag pairs to add subscript and superscript text to yo ur site, as shown in the fo llowing fo rmula: The value is equal to this equation: a1 + b2

Figure 5- 7 shows the result of putting all of this sectio n’s sample lines to gether to display fo rmatted HTML- based text.

Figure 5-7 Example s of fo rmatte d characte rs in HTML-base d te xt.

Part I I — Sat urday Morning Session 5

This sentence contains one underlined word.

70

Sat urday Morning

REVI EW 쐌 Yo u can create articles in a wo rd pro cesso r to help ensure grammar and spelling accuracy.

쐌 The articles that yo u create in a wo rd pro cesso r can be saved as a text file with the html ( o r htm) filename extensio n.

쐌 Yo u can create a template that wo rks as a starting po int fo r subsequent HTML Web pages.

쐌 Specify multiple fo nts so yo ur fo nt requests are fo llowed when po ssible. 쐌 The text- fo rmatting co mmand tag pairs and ; and ; and and indicate bo ldfaced, italicized, and strikethro ugh text, respectively.

QUI Z YOURSELF 1.

Why keep yo ur ho me page text to a minimum? ( See “ Text is the Fo undatio n.” )

2.

What do es a template help yo u do ? ( See “ Yo ur Web Page General Layo ut Template.” )

3.

Why do es so me Web text appear differently o n different co mputers? ( See “ Dealing with Specific Fo nt Limitatio ns.” )

4.

What is the difference between serif, sans serif, and mo no spaced fo nts? ( See “ Dealing with Specific Fo nt Limitatio ns.” )

5.

Which fo nt tag determines the fo nt size used fo r yo ur entire Web page unless overridden fo r specific text? ( See “ Fo nt Size.” )

SESSI ON

6 I mproving t he Look of Your Web Page’s Text

Session Checklist ✔ Align text, add line breaks, and use pro per spacing ✔ Add ho rizo ntal rules to separate headlines and articles ✔ Increase and decrease the fo nt size of yo ur text ✔ Understand fo nt selectio n co nsideratio ns ✔ Use lists in yo ur text to display detailed info rmatio n

I

n this sessio n, yo u learn how to spruce up the appearance of yo ur Web site’s text. As with printed do cuments, yo u can co ntro l the alignment, spacing, and size of yo ur text. Yo u can also add ho rizo ntal lines to separate bo dies of text

fro m headlines and to pro duce sectio ns o n yo ur Web page. In additio n, HTML suppo rts several kinds of list fo rmats that yo u can add to yo ur text to help o rganize the presented data.

Text Alignment and Spacing As with wo rd- pro cessed text, yo u can co ntro l the alignment and spacing of the text o n yo ur Web page. Fo r example, fo r detailed technical material that yo u make

72

Sat urday Morning

available o n yo ur site, yo u may want few separating blank lines. Fo r lighter material, the mo re whitespace yo u provide, the better the appearance.

Bet t er paragraph spacing As yo u learned in Sessio n 5, the

tag defines a new paragraph by inserting a do uble carriage return at the po int of the

so that subsequent text appears as a new paragraph fro m the previo us text. The

tag displays so mewhat strangely in so me browsers by adding to o much o r no t eno ugh spacing between paragraphs. To overco me this po tential pro blem, so me HTML pro grammers prefer to use two
tags in place of the

to ensure that exactly two carriage returns appear between paragraphs. Two carriage returns between two paragraphs, in effect, pro duce o ne blank line between them. Many of the newer browsers, such as Internet Explo rer 5, have an HTML interpreter that pro perly deco des a single

tag as two
tags, and o ther browsers are quickly beco ming mo re co nsistent. In the meantime, yo u may want to retain the de facto standard of using two
tags when yo u want exactly o ne blank line to appear between paragraphs.

Session 9 describes how you can use a 1 - bit pixel graphic image, an ext remely small image, t o space t ext and graphics precisely. Tip

Paragraph alignment The

tag with the align= attribute determines the left, right, o r centered alignment of the paragraphs in yo ur Web page. The fo rmat of the

tag fo llows:

No end tag appears because

wo rks in place of the

and begins a new paragraph by skipping o ne blank line ( in mo dern browsers) and beginning a new paragraph. In fact,

is the

tag with the o ptio nal align attribute. Witho ut the align attribute, the paragraph will always align to the left margin.

Session 6 — I mproving t he Look of Your Web Page’s Text

73

The and command t ag pair also cent ers paragraphs t o t he middle of t he screen’s margins, and of f ers t he addit ional benef it of cent ering graphic images. Tip

Figure 6- 1 shows the resulting three paragraph alignments pro duced by the fo llowing co de:

This paragraph will appear left-justified on the screen. The left edge of the paragraph will be straight while the right edge will be ragged. By the way, the ending paragraph tag is optional but good HTML programming style dictates that you include a closing paragraph tag with each start tag you put on your site.



This paragraph will appear centered in the middle of the screen. Both the left and right edges of each line will fit perfectly in the center of the screen. Notice that the HTML tags do not force the browser to align both the left and right edges. Both edges remain ragged when you center a paragraph.



This paragraph will appear right-justified on the screen. The right edge of the paragraph will be straight while the left edge will be ragged. Sometimes, a graphic image on the left side of the text makes the right-alignment a good option.

Yo u can apply the alignment tag to headlines as well as to bo dy text.

Part I I — Sat urday Morning Session 6

Never

Never at t empt t o f ully just if y paragraphs. Beginning in HTML 4 , a

t ag at t ribut e exist s, but many browsers of f er lit t le or no support for t his relat ively new t ag t hat at t empt s t o make bot h t he lef t and right edges of a paragraph st raight , as would appear in most newspaper columns.

74

Sat urday Morning

Figure 6-1 The

tag co ntro ls the alignme nt of yo ur paragraphs.

Line breaks and spacing When yo ur Web page users lo o k at yo ur pages, they might have their browsers set to full- screen mo de o r the browser windows might be smaller than the maximized window allows. Fo rtunately, the browser wraps yo ur HTML text to whatever window size the user displays. The auto matic wrapping feature is the primary reaso n why browsers do no t auto matically add line breaks when yo ur HTML co de includes text returns o n multiple lines. Co nsider the fo llowing HTML:

This is line one. This is line two. This is line three. In the browser window, this co de pro duces o ne co ntinuo us line that reads:

This is line one.This is line two.This is line three.

Session 6 — I mproving t he Look of Your Web Page’s Text

75

If the browser added line breaks at the end of every line of text and, in additio n, the browser wrapped lines auto matically when the user resized the browser window, yo ur text co uld end up lo o king very strange indeed. That’s why yo u decide when yo u want the line breaks. No t o nly do browsers igno re returns in yo ur text, but also they do no t reco gnize the tab character o r multiple spaces that yo u might embed in text while wo rking in yo ur text edito r. Tabs, multiple spaces, and returns all co llapse into a single space Web page paragraphs, several o ptio ns are available, few of which are extremely elegant. Fo r example, a tag exists that enables yo u to provide exact ho rizo ntal and vertical adjustment of text, but no t all browsers suppo rt . Perhaps that’s why few paragraphs of text ever appear o n Web pages with the first line indented. Yo u can also pre- fo rmat yo ur HTML text; that is, yo u can request that the browser respect the same text spacing that yo u used when yo u entered the text. One way is to use the and tags. Any text that yo u enclo se between

and retains the spacing yo u used, such as an indent in the first line of yo ur paragraph. The fo llowing HTML co de ensures that the paragraph’s first line is indented and that each line spans a separate line in the browser’s window:

HTML is the abbreviation for HyperText Markup Language. HTML simplifies Web page formatting. In addition to text formatting, HTML formats the placement of graphic images on your page.

Quot ing long passages The and tags are useful fo r quo ting lo ng passages of text. These tags fo rmat the text that they enclo se by indenting the left and right margins of the text — shrinking and setting apart the text fro m the surro unding paragraphs. No additio nal

o r
tags are required. Figure 6- 2 shows the result of the fo llowing HTML co de, which fo rmats a lo ng quo te:

Philosophical Thought

Part I I — Sat urday Morning Session 6

when viewed in the browser window. To add indentio ns at the beginning of yo ur

76

Sat urday Morning

The line from Plato to St. Augustine to John Calvin links the thoughts of each. Calvin’s theology is rooted deeply in Greek philosophy and today’s Calvinists thank Plato for their beliefs. As Dr. Hill states,

”First we must see the origin. Immutability means unchanging. This is the basis for many of the tenets of Calvinistic doctrine. But, where did the idea of immutability come from? The answer is Plato. “

Figure 6-2 Lo ng quo te s lo o k go o d whe n fo rmatte d with the tag.

Separat ing Text wit h Horizont al Rules One of the best ways to separate blo cks of text, even headlines fro m the bo dy text within articles, is to add a ho rizo ntal, separating line between the blo cks. In HTML termino lo gy, such a line is called a ho rizo ntal rule.

Session 6 — I mproving t he Look of Your Web Page’s Text

Tip

77

Horizont al rules enable you t o underline complet e lines of t ext or headlines wit hout resort ing t o a t rue underline t hat is more easily conf used wit h a hyperlink. I n addit ion, a horizont al rule does not preclude t he possibilit y of making your headline a hyperlink; in ot her words, a headline can be a hyperlink as well as sit at op a horizont al rule.

The tag pro duces a ho rizo ntal rule. The rule is gray and has a 3- D effect. o nce with a single rule and o nce with two ho rizo ntal rules. By adding multiple ho rizo ntal rules, yo u can add an artistic effect to yo ur articles.

Philosophical Thought

The line from Plato to St. Augustine to John Calvin links the thoughts of each. Calvin’s theology is rooted deeply in Greek philosophy and today’s Calvinists thank Plato for their beliefs. As Dr. Hill states...



Philosophical Thought

The line from Plato to St. Augustine to John Calvin links the thoughts of each. Calvin’s theology is rooted deeply in Greek philosophy and today’s Calvinists thank Plato for their beliefs. As Dr. Hill states...

Figure 6- 3 shows the resulting Web page that co ntains the three ho rizo ntal rules.

The gray rule is somewhat boring, but ef f ect ive. You can use graphic images t o creat e more colorf ul rules if you pref er, as Session 9 shows. Not e

Part I I — Sat urday Morning Session 6

The fo llowing co de repeats a headline and the beginning of the article twice,

78

Sat urday Morning

Figure 6-3 Ho rizo ntal rule s he lp se parate he adline s fro m article s.

The tag suppo rts several attributes with which yo u can change the way the rule appears o n yo ur Web page. Yo u can add a size= attribute to co ntro l the number of pixels used in the line. The fo llowing tags display ho rizo ntal rules at different widths:



In additio n to specifying the width in pixels, yo u can align the rule to the left, center, o r right edge of the browser window with the align attribute, like this:

Of co urse, alignment seems to make no sense, because the rules yo u’ve seen so far all span the entire browser window width. But yo u can specify an o ptio nal width attribute that co ntro ls the width of the rule. Specify the width attribute as

Session 6 — I mproving t he Look of Your Web Page’s Text

79

a percentage of the browser window. The fo llowing tag displays a 3- bit pixel ho rizo ntal rule that spans 25 percent of the browser window and is aligned against the right edge of the window. ( The start of the rule begins 75 percent to the right of the window.)

Altho ugh usually frowned upo n by HTML pro grammers, yo u’ll see the tags ,

, , and thro ugho ut the Web pages that yo u visit, and yo u might even find yo urself reso rting to them in a pinch. These tags increase and decrease the fo nt size o n yo ur Web page. CSS, as yo u’ll learn in Sessio n 20, is reducing and, in many instances, eliminating the need fo r many text- fo rmatting tags such as these. The and tags base themselves o n the size of the do cument’s fo nt, set by a tag earlier in the do cument. Every time the browser co mes upo n a tag, the browser increases the text size fo r subsequent text until a co rrespo nding tag appears. Fo r example, if yo u place two tags befo re a end tag, the browser displays the enclo sed text two sizes larger than the size, and so o n. The and tags wo rk in the o ppo site manner, by making the text smaller than the current size with each o ccurrence of . The wo rds in the fo llowing example beco me larger and smaller acco rding to the co mmand tags:

These words grow larger and larger..

These words get smaller and smaller. Figure 6- 4 shows the result of this co de in a Web page.

Part I I — Sat urday Morning Session 6

Bigger and Smaller Font Sizes

80

Sat urday Morning

Figure 6-4 The and tags incre ase and de cre ase fo nt size.

Addit ional Font Select ion Considerat ions Mo st co mputer screens display 72 pixels per inch, so a 12- po int character appears o n the screen in a o ne- sixth inch of height. A 12- po int character offers little ro o m fo r the serifs that co me o n many fo nts, especially the mo re elegant fo nts such as Go thic and slanted script fo nts.

Not e

Technically, dif f erent font names specif y dif f erent t ypefaces. A t ypeface such as Schoolbook dif f ers f rom t he t ypeface of Times New Roman. Of t en, programmers use t he more general t erm font t o ref er t o t he dif f erent font names, and t hat loose usage will cont inue here.

Do n’t give in to the need to make gigantic headlines. Check o ut the po pular sites o n the Web, such as Micro soft ( http://www.microsoft.com/) and Yaho o ! ( http://www.yahoo.com/) , and yo u’ll see that they do no t make use of overly large headlines. Instead, they are able to fit mo re info rmatio n o n the page that wo uld o therwise be wasted o n ugly, large type.

Never

Never mix t oo many font s on a page. I f you f ind yourself using four or more font s on t he same Web page, you are probably using t oo many and your page will seem more like a ransom not e t han a calm, readable, and uniform page. Try t o keep similar font s on similar element s; t hat is, use t he same font for all headlines, t he same font for all t it les, and t he same font for all hyperlinks t hat appear on t he same page.

Session 6 — I mproving t he Look of Your Web Page’s Text

81

To day’s browsers do a fairly go o d jo b at fo nt substitutio n. Fo r example, if yo u specify a sans serif fo nt that is unavailable o n the user’s system, the browser can often reco gnize that the fo nt is a sans serif fo nt and substitute ano ther. If, however, yo u use less co mmo n fo nts that yo u buy fro m third-party fo nt dealers, the chances are less likely that the browser will be aware of that fo nt’s name. No matter how go o d yo ur special fo nts make a Web page appear, sticking with the simple o nes will make yo ur pages mo re unifo rm o n mo re systems. If yo u truly need to utilize a file as an image. The same image, therefo re, will appear in every Web browser. Keep yo ur eyes o n new browser techno lo gies that appear in the future. A move is under way to provide the downlo ading of fo nts fro m a Web server to the user’s system. Once downlo ading of fo nts is available, yo u can use any fo nt available o n yo ur own co mputer fo r Web design, and that fo nt will be sent to the user’s co mputer if the user do esn’t have that fo nt ( assuming the user o kays the fo nt downlo ad, presumably) . No fo nt downlo ading standards have been universally approved, altho ugh Micro soft has designed the Ope nType fo nt- downlo ading system and Netscape has its Dynamic Fo nts system in place. Keep checking the W3 Web co nso rtium ( http://www.w3.org/) fo r news o n which downlo ading standard beco mes the accepted no rm. Altho ugh the downlo ading of fo nts will add time to the site’s arrival o n the user’s system, Internet speeds are always increasing. In additio n, o nce the fo nts pro liferate, downlo ading will beco me less frequent as users accept mo re and mo re fo nts arriving with their asso ciated Web pages.

Put t ing List s in Your Text Given that the Web is used to disseminate info rmatio n, often that info rmatio n presents well in a list fo rmat. HTML makes presenting yo ur data in list fo rm easy by suppo rting several list tags. With HTML, yo u can add the fo llowing kinds of lists to yo ur Web pages:



Orde re d lists that present info rmatio n in an o rder, such as the steps needed

to bake a recipe



Uno rde re d lists that present info rmatio n that do es no t fall in a given o rder,

such as a list of pro ducts that yo u sell o n yo ur Web site



De finitio n lists that present terms and definitio ns where the definitio ns are

indented and appear below the terms

Part I I — Sat urday Morning Session 6

special fo nt, create the text in a graphics pro gram such as Illustrato r and save the

82

Sat urday Morning

Ordered list s The tag begins an o rdered list o n yo ur Web page. Within the list, yo u need to precede each item with the
  • tag ( no end
  • tag exists) so the browser knows where each item in the list begins. At the end of the list, the tag ends the o rdered list. The fo llowing co de describes how to start a car:

  • Put the key in the ignition.
  • Turn the key.
  • When the engine turns over, release the key.

    When yo ur Web page co ntains this co de, the browser auto matically numbers the list, beginning with 1. The nice thing abo ut the browser’s auto matic numbering, as o ppo sed to yo u numbering the list yo urself, is that yo u can add items, remove items, and rearrange items in the list witho ut having to renumber the list yo urself. The browser will always renumber the list befo re each display. Figure 6- 5 shows how the list appears in the browser window.

    Figure 6-5 The browse r auto matically numbe rs o rde re d lists.

    Unordered list s Uno rdered lists are easier to create than o rdered lists because no starting value exists. By default, the browser displays a bulle t, a shaded circle, at the beginning of each item in the list. The fo llowing co de creates an uno rdered list:

    • CPU

      Session 6 — I mproving t he Look of Your Web Page’s Text

      83

    • Hard disk
    • CD-ROM
    Figure 6- 6 shows how the list appears in the browser window.

    Each ite m in an uno rde re d list be gins with a bulle t.

    Yo u can override the bullet style with the type attribute. The type attribute must appear inside quo tatio n marks and can be o ne of the values fro m Table 6- 2.

    Table 6 -2 Uno rde re d Type Attribute s

    Type name

    Bulle t’s appe arance

    circle

    Circle with clear center

    disc

    Circle with filled, dark center

    square

    Square with filled, dark center

    Definit ion list s Use the tag to begin a definitio n list. Each term in the definitio n list must begin with the tag, and each detailed line of the definitio n list must begin with the tag. Altho ugh definitio n lists may so und mo re co mplicated than the previo us list styles, definitio n lists are easy to understand o nce yo u see o ne pro duced. The fo llowing co de pro duces a definitio n list that might appear as part of a self-defense site:

    caliber

    Part I I — Sat urday Morning Session 6

    Figure 6-6

    84

    Sat urday Morning

    The internal diameter of the barrel of a gun or of a bullet casing. centerfire A gun that fires ammo by striking the center pin in the cartridge. recoil The kick that you experience when a firearm presses back against you during firing.

    Figure 6- 7 shows how the definitio n list appears in the browser window.

    Figure 6-7 The de finitio n is inde nte d fro m the te rm in a de finitio n list.

    Not e

    Def init ion list s aren’t just for def init ions. You can use def init ion list s t o describe ot her Web sit e links, using t he Web sit e name or URL as t he t erm and format t ing t he sit e’s descript ion as t he def init ion. Name and address list s also work well in def init ion list format .

    REVI EW 쐌 Be careful when using

    because of the inco nsistency that so me browsers provide with handling spaces between paragraphs.

    쐌 By aligning yo ur text with the left edge of the browser window, the center of the window, o r the right edge of the window, yo u create a better page layo ut fo r yo ur text.

    Session 6 — I mproving t he Look of Your Web Page’s Text

    85

    쐌 Keep yo ur text fro m wrapping when the user resizes the browser window. 쐌 The tag sets off lo ng passages of text, such as a quo tatio n. 쐌 Yo u’ll see the and tags still in use, but a move is under way to sto p using them because of the increased usage of style sheets.

    쐌 HTML makes adding lists to yo ur Web sites easy with the ,

      , and tags.

      1.

      What can yo u use as a substitute fo r the

      tag to ensure that yo ur paragraphs break with a single blank line between them? ( See “ Better Paragraph Spacing.” )

      2.

      Which tag substitutes fo r

      and enables yo u to center graphic images as well as paragraphs? ( See “ Paragraph Alignment.” )

      3.

      What is the primary reaso n why browsers do no t auto matically add line breaks when yo ur HTML co de includes text returns o n multiple lines? ( See “ Line Breaks and Spacing.” )

      4.

      What are the tags still in use that make text larger o r smaller than the base size? ( See “ Bigger and Smaller Fo nt Sizes.” )

      5.

      What is the difference between the three list styles? ( See “ Putting Lists in Yo ur Text.” )

      Part I I — Sat urday Morning Session 6

      QUI Z YOURSELF

      SESSI ON

      7 HTML Graphics

      Session Checklist ✔ Add graphics to yo ur Web page and master the two primary graphic file types ✔ Use the tag to wo rk with images o n yo ur Web pages ✔ Specify the width and height of yo ur images ✔ Deal with users who turn off their image display ✔ Distinguish between interlaced and no ninterlaced images ✔ Adjust yo ur images’ gamma value

      I

      n this sessio n, yo u’ll learn the mechanics of placing graphic images o n yo ur Web pages. Yo u’ll also learn what attributes to use to speed up the lo ading of graphics and to get aro und users who turn off their image display. Much

      of what yo u learn this weekend abo ut Web page graphics centers no t o nly o n the actual HTML tags needed to display the images, but also o n the graphic theo ry required to use graphics effectively.

      88

      Sat urday Morning

      Kinds of Graphics and File Types The term picture actually do esn’t describe all the kinds of images a Web page can display. Yo ur Web page can display pictures, line drawings, co mputer- generated artwo rk, scanned images, images bro ught into the machine fro m an electro nic drawing tablet, images fo r free and fo r sale o n the Internet, clip art that co mes with drawing pro grams, and even mo use- drawn images created in paint pro grams. If yo ur co mputer can create o r lo ad it, a Web page can display it. The mo re graphics- intensive yo ur site is, the mo re visually appealing that it may be. However, it is less likely that users will wait o n the site to lo ad befo re giving up and go ing elsewhere. Obvio usly, if yo ur site is a graphics- o riented site, as wo uld be the case fo r an art gallery’s preview site, users know what to expect and are willing to wait lo nger than a po tential custo mer who simply wants to know what time yo ur custo mer service perso nnel begin wo rking. And, as yo u already know fro m Friday evening’s sessio ns, yo u sho uld keep yo ur ho me page free of intensive graphics no matter what service yo ur site provides and bury the intensive graphics deeper in the site where yo ur users will stick with yo u mo re. Many different graphic images exist. Yo u can lo cate graphic files sto red with many filename extensio ns, but yo u sho uld use o nly two image types when placing images o n yo ur Web page, and they are as fo llows:



      GIF ( pro no unced “ jiff” ) files, also known as graphic inte rchange fo rmat

      files, were o riginally develo ped fo r the Co mpuServe o nline service. GIF files can display up to 256 co lo rs and wo rk well fo r images with pure co lo rs such as lo go s and paint- pro duced pro grams.



      JPEG o r JPG o r JPE ( pro no unced “ j-pe g” ) files, created fo r the Jo int Pho to graphic Expe rts Gro up, can display millio ns of co lo rs and are great fo r

      high- reso lutio n images such as pho to s.

      Never

      Never embed an image wit h anot her f ile ext ension on your sit e, because a browser does not support ot her graphics f ile format s. Most graphics programs will convert your image t o GI F or JPG format wit h t he File ➪ Save As command.

      Generally, yo u’ll use the JPEG fo rmat fo r pho to graphic images and GIF fo r all o ther kinds of graphics yo u place o n yo ur Web pages. JPEG’s high availability of co lo rs makes JPEG a go o d standard fo r pho to s. Small text o n to p of a JPEG image do es no t always display well because the edges can lo o k ro ugh and grainy. That’s why GIF wo rks well fo r lo go s and o ther images that typically include text as well as a graphic.

      Session 7 — HTML Graphics

      89

      GIF images also provide exceptio nal suppo rt fo r a co ncept called transpare ncy. Yo u can specify a co lo r o n a GIF image that will be transparent to its backgro und.

      Session 1 5 describes more about creat ing and placing t ransparent images on your pages. Cross-Ref

      images with a high reso lutio n, yo u are wasting page- lo ading time. The o ne exceptio n is when yo ur users want to print yo ur site’s images. Printer reso lutio ns are higher than mo nito r reso lutio ns, with so me reaching 1200 dpi. Instead of providing these kinds of graphics o n yo ur primary Web pages, however, yo u may want to offer a Web page with special printer versio ns of images that yo ur users may need to print.

      Working wit h Graphics Wo rking with images o n yo ur Web page takes little effo rt. The ( fo r image ) tag do es all the wo rk fo r yo u. The tag suppo rts several attributes, but the src= ( fo r so urce ) attribute is the o ne that specifies the name and lo catio n of the image.

      Placing an image Here is the fo rmat of the tag that co llects the graphic image and displays the image o n the Web page:

      No end tag is necessary. The lo catio n of image generally is the images fo lder yo u’ve sto red in the same lo catio n as yo ur site’s HTML files. Yo u also can add a link to an image lo cated o n ano ther Web site. If yo u first co py that image to yo ur own site’s images fo lder and refer to that co py, assuming yo u have permissio n to co py and use the image, yo ur Web site link will remain go o d even if the o ther site changes. The fo llowing tag tells the browser to lo cate and display the image named

      ourhouse.gif:

      Part I I — Sat urday Morning Session 7

      When preparing yo ur images, remember that mo st co mputer mo nito rs have 72 pixels per inch ( usually referred to as dpi o r do ts pe r inch ) reso lutio n. If yo u offer

      90

      Sat urday Morning

      If yo u co mbine this tag with o ther tags, the image appears inline with surro unding text. In such a case, the text and the image take different places o n the screen. The fo llowing co de pro duces the image shown o n the browser screen in Figure 7- 1.

      Welcome to our new home Although we are snowed in, we love it here in the country.

      (At least the gravel road doesn’t stir up much dust in the winter!)



      Figure 7-1 The tag le ts yo u display image s o n yo ur page.

      Session 7 — HTML Graphics

      91

      Framing an image Yo u can add a bo rder aro und yo ur images by using the border= ( fo r bo rde r) attribute inside the tag. If yo u specify a bo rder value higher than 0, the browser will place a bo rder aro und the image. The fo llowing co mmand tag draws a bo rder ten pixels wide aro und the image:

      Aligning an image As with paragraphs, yo u can align graphic images to the left edge, center, o r right edge of the browser window. The align=left ( fo r align le ft ) and align=right ( fo r align right ) attributes handle the left and right alignment. Insert either

      align=left o r align=right in the tag when yo u want to align the image against the window edge. The fo llowing tag places the image against the window’s right edge and adds a 10- pixel bo rder, as shown in Figure 7- 2:

      To center an image, enclo se the image between the and tags like this:



      Not e

      The align at t ribut e overrides a t ag t hat may st ill be in ef f ect . I n ot her words, if an image appears inside a and pair of t ags, and t hat image cont ains an align=right at t ribut e, t he image will be right - aligned and not cent ered in t he browser’s window.

      Part I I — Sat urday Morning Session 7

      Not e

      Keep in mind t hat many format t ing command t ags, including t hese graphic t ags, are also support ed by CSS, t he cascading st yle sheet s t hat you’ll learn about in Session 2 0 . I n addit ion, you can learn CSS rapidly af t er you’ve seen how t he individual t ags work t o format pages.

      92

      Sat urday Morning

      Border

      Figure 7-2 The image is right-aligne d against the window e dge with a frame d bo rde r.

      Specifying t he I mage Size When a browser lo ads a Web page that co ntains o ne o r mo re images, the browser must calculate the size of each image to make ro o m fo r the graphics and to fo rmat the o ther text and images. Yo u can speed the lo ading of the pages yo u create with HTML by specifying image sizes inside the tag. Yo u can specify the number of pixels, high and wide, that the image requires.

      Most of t oday’s graphics programs can det ermine t he exact pixel size of any image and display t he size. You can of t en locat e t he image size in t he menu opt ion labeled Propert ies. Tip

      Use the width= ( fo r width ) attribute to specify the image’s pixel width, and use the height= ( fo r he ight ) attribute to specify the image’s pixel height. The

      Session 7 — HTML Graphics

      93

      fo llowing line displays an image o n the Web page at an exact width of 600 pixels and a height of 400 pixels:

      You can combine all of t he at t ribut es you’ve seen in t his session in a single t ag.

      When yo u specify the inco ming graphic’s size, yo u no t o nly save lo ading time, but yo u also can resize the image to grow o r shrink in the receiving Web page. If yo u specify a width and height attribute value that is smaller than the image’s actual size, the Web page will shrink the image. If yo u specify a width and height attribute value that is larger than the image’s actual size, the Web page will expand the image. The actual width and height attributes o nly shrink o r grow the image’s size o n the Web page but do no t speed up o r slow down the lo ading of the image. In o ther wo rds, the full image lo ads with the Web page, and the width and height attributes o nly determine the size at which the Web page will display the image in the browser window.

      Never

      Never change an image ’s height or widt h value by it self unless you want t he image t o appear out of proport ion. I n ot her words, if you want t o shrink t he widt h of an image by 2 5 percent , be sure t o specif y a height at t ribut e value t hat is also 2 5 percent smaller t han t he image ’s original size.

      Figure 7- 3 shows the same image with three different sizes. The first image is displayed witho ut height and width attributes in the tag, so the image co mes in at its actual size. The seco nd image is smaller because of smaller height and width attributes, and the third image is larger because of larger height and width attributes. Keep in mind that an image do es no t actually grow o r shrink when yo u change the height and width attributes. The image’s o riginal size determines what the browser receives, and the tag determines how the browser displays the image. If, fo r example, yo u attempt to display a larger image that runs far past its o riginal width and height size, the image will appear grainy because there is no t eno ugh of the image to expand well past a given po int.

      Part I I — Sat urday Morning Session 7

      Tip

      94

      Sat urday Morning

      Figure 7-3 The same image appe ars o n this We b page in thre e diffe re nt size s.

      If yo u want to take an image and expand its size dramatically, and the expansio n causes the image to appear grainy o n receiving Web pages, co nsider lo ading that image into a graphics pro gram such as PaintSho p Pro and enlarging the actual image. The graphics pro gram can help co rrect co lo r and reso lutio n pro blems that might arise when yo u grow the image to o large in HTML. Of co urse, increasing the size of the image in the graphics pro gram also increases the lo ading time when that larger image lo ads in the Web page. Lo ading time versus reso lutio n is o ne of the trade- off issues that yo u’ll co nstantly balance as yo u develo p Web pages.

      Tip

      Not e

      Some graphics programs will remove header informat ion t hat comes embedded in many GI F images. You can reduce t he size of a GI F image by 1 0 percent and speed loading t ime by removing t he image’s header informat ion. Many HTML programmers at t empt t o keep t heir home pages 3 5 K or less, meaning t hat t he t ot al size of t he home page, including all t ext and graphics, comes t o no more t han 3 5 K. Even t his size can be t oo slow, so at t empt t o make t he size as compact as possible. A 3 5 K Web page t akes about 2 5 seconds t o download using a low- end 1 4 .4 Kbps modem, and 1 2 t o 1 5 seconds using a 2 8 .8

      Session 7 — HTML Graphics

      95

      Kbps modem, which is t oo long for some users t o wait . Many Web pages are far great er t han 3 5 K, and such a limit can be ext remely f rust rat ing. The good news is t hat t he ent ire I nt ernet speed, it s bandwidt h, should be moving fast er as t echnologies improve.

      When Users Turn Off t he I mage Display Therefo re, yo u must co nstantly keep tho se users in mind when designing yo ur Web page. Obvio usly, if yo ur Web page’s missio n is to display pictures o r show artwo rk, yo u can co nscio usly cater to the users who have high- speed Internet co nnectio ns o r to users who do n’t mind waiting o n the images to lo ad. The tag suppo rts the o ptio nal alt= ( fo r alte rnative image ) attribute that lets yo u display text in place of an image whenever the user turns off the display of graphics in the browser. The text that fo llows the alt= tag, enclo sed in quo tatio n marks, appears in the user’s browser window when graphics are turned off. The user, therefo re, knows what the image is suppo sed to be and can either decide to view that particular graphic image by clicking it o r igno re the image and co ncentrate o n the text. Generally, yo u sho uld add alternate text to yo ur tags whenever yo u place images o n yo ur page. The fo llowing line displays the message, Jayne’s Picture, instead of the actual picture if the user’s images are turned off:

      Figure 7- 4 shows a Web page with the graphic images turned off but with alternative text descripto rs that describe what the user do es no t see.

      Tip

      Even if t he user ’s graphics are t urned on, t he alt= at t ribut e provides an addit ional benef it . When t he user hovers t he mouse point er over t he image, t he t ext pops up in a small box next t o t he mouse point er. Therefore, t he user might point t o an image t o read what your alt ernat ive at t ribut e says about t he image. Therefore, make your alt= at t ribut e values descript ive.

      If yo u place bo rders aro und images that are deco rative o n yo ur Web page, yo u sho uld specify the alt= attribute fo r tho se images, to o , so that text can be displayed instead of the actual bo rder. Use a blank attribute value o n such images, as do ne here:

      Part I I — Sat urday Morning Session 7

      As no ted in Sessio n 3, so me users turn off the lo ading of graphic images.

      96

      Sat urday Morning

      Alt ernat e image t ags

      Figure 7-4 The alte rnative te xt give s the te xt-o nly browse r info rmatio n abo ut the picture s.

      As an added bo nus fo r users who display pages with images turned off, if yo u specify the size of each image using the height= and width= attributes, the browser pads the space where the image wo uld no rmally go instead of displaying an unpadded, small ico n. The difference is that the browser respects yo ur page layo ut and do es no t change the lo catio n and spacing of headlines and o ther elements that might appear o n yo ur page. In Figure 7- 5, the browser pro perly fo rmats the page layo ut, even tho ugh graphics are no t present, because of the width= and

      height= attributes o n each of the graphic’s tags. Figure 7- 6, o n the o ther hand, shows a jumble of ico ns; the browser do es no t lay o ut the page pro perly because it canno t make guesses as to how wide and high the images are suppo sed to be witho ut the pro per attributes.

      Session 7 — HTML Graphics

      97

      Part I I — Sat urday Morning Session 7

      Figure 7-5 With the width and he ight me asure me nts, ro o m is allo cate d fo r the actual image s.

      I nt erlaced versus Nonint erlaced I mages An inte rlace d image is a GIF image that appears blurry at first and then slowly gets crisper as the page lo ads. A no ninterlaced image will no t appear in the user’s browser window until the browser gets the entire image. However, an interlaced image will appear altho ugh seemingly o ut of fo cus. The browser gets the image a layer at a time, with each layer making the image crisper and clearer. Nevertheless, even the blurred first o r seco nd versio n of the image that appears as the page lo ads is often eno ugh fo r the user to see what the image ho lds and make a decisio n to wait based o n the first impressio n.

      I nt erlaced JPEG images, called progressive JPEGs, are now available but f ew browsers support t hem. Not e

      98

      Sat urday Morning

      Figure 7-6 Witho ut width and he ight me asure me nts, the page layo ut is harme d.

      The user might want to see the image in its final fo rm, o r the user might o pt to traverse to a different Web site befo re the image clears up. Either way, the user has the cho ice to decide so o ner than wo uld be po ssible if the image were a no ninterlaced image. The decisio n to use interlacing is no t do ne at HTML co ding time. Instead, yo u determine whether o r no t an image is interlaced when yo u save it in a graphics pro gram. As an HTML pro grammer, yo u sho uld care abo ut interlaced images because they affect how yo u want to design yo ur site. If yo u want yo ur images to be hidden until the entire image arrives o n the user’s page, do n’t use interlaced images. Yo u will save so me lo ading time because no ninterlaced images lo ad faster altho ugh the user wo n’t see any of the image until the entire image arrives in the browser.

      99

      Session 7 — HTML Graphics

      Gamma Correct ion PC mo nito rs generally display images 20 percent darker than Mac mo nito rs do . When yo u develo p a graphic image in a graphics pro gram, the pro gram’s gamma co rre ctio n enables yo u to lighten o r darken the images to adjust the gamma value,

      o r the value that determines the brightness. PCs usually require a gamma co rrectio n of 2.2 while the Mac requires a 1.7 to 1.9 gamma. As an HTML pro grammer, graphics do n’t lo o k co rrect o n either a PC o r a Mac, yo u may have to adjust the gamma value fo r tho se images in a graphics pro gram.

      REVI EW 쐌 Graphics add flair to yo ur Web site. 쐌 JPEG images are generally used fo r pho to s, and GIF images are generally used fo r all o ther artwo rk.

      쐌 Keep in mind the trade- off of lo ading speed versus graphic reso lutio n. 쐌 The tag with the align=left and align=right attributes lets yo u left- and right- align yo ur images pro perly in the Web page window.

      쐌 The border= attribute inside the tag lets yo u add bo rders aro und the images yo u want framed o n yo ur Web page.

      쐌 The tag suppo rts the o ptio nal alt= attribute that lets yo u display text in place of yo ur graphic images.

      QUI Z YOURSELF 1.

      Which graphics type is best fo r lo go s? ( See “ Graphic File Types.” )

      2.

      What is the screen reso lutio n of mo st mo nito rs? ( See “ Graphic File Types.” )

      3.

      How can yo u center an image in the window? ( See “Aligning an Image.” )

      4.

      True o r False: When yo u decrease the display size of an image by specifying small width= and height= attributes, yo u increase the page- lo ading speed. ( See “ Specifying the Image Size.” )

      5.

      Why wo uld yo u ever use a blank alt= attribute fo r an image o n yo ur Web site? ( See “ When Users Turn Off the Image Display.” )

      Part I I — Sat urday Morning Session 7

      yo u may wo rk with whatever images yo u receive, but if yo u see that yo ur page’s

      SESSI ON

      8 Working wit h Color in Text and Graphics

      Session Checklist ✔ Determine yo ur Web page’s co lo r strategies ✔ Use co lo r co des to specify exact co lo rs ✔ Utilize browser- safe co lo rs to make yo ur Web site universal ✔ Add co lo r to text and yo ur Web page backgro und

      B

      e fo rewarned — this sessio n co ntains so me co lo r theo ry and less hands- o n HTML co ding than any sessio n so far. If yo u are no t an artist, yo u may have little interest in learning abo ut co lo rs and co lo r palettes. However,

      understanding co lo rs as they apply to the Web is far different fro m understanding co lo rs that an artist must master. Here, yo u learn how to use Web co lo rs so that they display pro perly as o ppo sed to the millio ns of co lo rs that will mislead yo u into thinking that yo ur Web page lo o ks like what yo u intended when it do es no t.

      102

      Sat urday Morning

      Color St rat egies: Codes and Safe Colors Altho ugh there might be so me o ne so me whe re using a mo no chro me mo nito r to browse the Web, yo u can igno re this lo nely user and assume that yo ur Web page users are go ing to be seeing yo ur pages in glowing co lo rs. In additio n, yo u can assume that yo ur users will view yo ur Web pages in mo re than 200 rich co lo rs. 200 o r mo re co lo rs o ught to be eno ugh to satisfy any Web designer, right? It turns o ut that 200 o r so co lo rs provide an extremely limited pale tte ( the co lo r co llectio n) of co lo rs fro m which yo u can use o n yo ur pages. A pho to graph co ntains millio ns of co lo rs, with many co lo rs shading and radiating into o ther co lo rs and moving to many different hues and tints. Yo u’ll recall fro m the previo us sessio n that JPEG files can co ntain millio ns of co lo rs. Such files immediately and co nsiderably downgrade in quality when viewed with little mo re than 200 to tal available co lo rs.

      Tip

      I f you have JPEG images t hat you want t o display on your Web page, and you use a paint program t o decrease t he number of colors in t hat image, you may act ually increase t he f ile size and t he t ime it t akes t o download an image! JPEG images are opt imized t o display a wide range of colors as ef f icient ly as possible. You are usually bet t er of f just let t ing t he JPEG image load int o t he reduced color palet t e. Decreasing colors of your GI F f iles, on t he ot her hand, can reduce bot h t he f ile size as well as t he image’s loading t ime.

      Color codes and palet t es The three co lo rs red, green, and blue co mbine differently to repro duce every co lo r in nature. Actually, the human eye interprets co mbinatio ns of these co lo rs as o ther co lo rs. When the human eye sees red and green, a yellow tint fo rms fro m that co mbinatio n. Perhaps yo u’ve heard the terms RGB inputs o r RGB mo nito rs. The RGB simply stands fo r re d, gre e n, and blue and describes inputs o r mo nito rs that co mbine these three co lo rs to pro duce all o ther co lo rs that peo ple see o n such devices. Therefore, every color you see on a computer screen is comprised of a combination of red, green, and blue. To see the pure red color, for example, your monitor forms a combination of full red, no green, and no blue. Thought of another way, your monitor uses 100 percent of red, 0 percent of green, and 0 percent of blue to produce the red color. To produce the color cyan ( had anyone really heard of the color cyan before the first PC color graphics card used something called cyan as one of its 16 colors?) , which

      Session 8 — Working wit h Color in Text and Graphics

      103

      is an aqua blue, your monitor uses 0 percent red, 100 percent green, and 100 percent blue to produce this blue-green color. Given the digital fo rmat of co mputer data, a single byte o r memo ry lo catio n can represent the value 0 thro ugh 255 ( fo r a to tal of 256 numbers) . Therefo re, to represent different co lo rs, a three- number co lo r co de is used to represent different co mbinatio ns of co lo rs. Gray requires an equal amo unt of light red, light green, and light blue. Instead of using the percentage scheme of 50 percent red, 50 0 to 255 to represent co lo rs. Therefo re, gray wo uld be 128- 128- 128. Many Windows pro grams offer a co lo r palette, such as the o ne in Wo rd 2000 shown in Figure 8- 1, to show a co lo r range fro m which yo u can select. No tice the co lo r values, red, green, and blue, with the values 0 thro ugh 255 next to each co lo r to specify the co lo r- co de co mbinatio n. Yo u can usually click o n a co lo r, and the pro gram auto matically determines the three- co lo r number co mbinatio n needed to represent the cho sen co lo r. In additio n, yo u can enter the three numbers next to Red, Green, and Blue, and the selectio n to o l moves to that co lo r in the vast co lo r array.

      These t hree numbers produce an individual color

      Figure 8-1 A co lo r pale tte auto matically displays co lo r co de s and pro duce s co lo rs.

      By providing these palette selectio n to o ls, pro grams so mewhat hide the threenumber co mbinatio n that go es o n under the co mputer’s ho o d to pro duce the co lo rs that yo u see. In o ther wo rds, if yo u want to select a custo m co lo r fo r a wo rd pro cessing do cument, yo u o nly have to display the palette and click o n the co lo r witho ut wo rrying abo ut the three-number co mbinatio n that represents that co lo r internally.

      Part I I — Sat urday Morning Session 8

      percent green, and 50 percent blue, the co mputer uses the numeric range fro m

      104

      Sat urday Morning

      If yo u co de in HTML ( fo r a to tal of 256 numbers) , however, the pro blem is that yo u do no t have such a palette in a text edito r. Even tho ugh so me text edito rs now suppo rt co lo r palette selectio ns ( yo u can click a co lo r, and the edito r auto matically places the numeric co mbinatio n in yo ur co de) , yo u must understand co lo rs and how the co mputer displays them in mo re detail than yo u wo uld if yo u pro grammed with so mething o ther than HTML. The bo tto m line is that yo u often must specify co lo rs in yo ur Web page using the numeric co lo r co des.

      Browser-safe colors If yo u multiply 256 times 256 times 256 ( with each 256 representing o ne of three- number co lo r co des) , yo u get a large pro duct — 16,777,216 co mbinatio ns to be exact. Altho ugh nature co ntains an infinite amo unt of co lo rs in the analo g co lo r spectrum, 16 millio n co lo rs is an ample supply of co lo rs fo r yo ur site. Nevertheless, a pro blem exists with a vast number of yo ur users’ systems in that they use 8- bit co lo r cards and, co nsequently, even tho ugh they can display mo re than 16 millio n co lo rs, they can display o nly 256 of tho se co lo rs at any o ne time. Therefo re, yo ur Web sites sho uld co ntain no mo re than 256 co lo rs o n the page at o ne time.

      Not e

      8 - bit color cards allow for t he display of only 2 5 6 colors at once because 0 t hrough 2 5 5 is t he range t hat can be represent ed in 8 bit s of binary ( t he base- 2 numbering syst em used inside your comput er) .

      To make matters wo rse, Windows-based co mputers suffer further because Windows reserves 20 co lo rs fo r its own use. That leaves o nly 236 co lo rs that yo u can be sure will be available to yo u. Altho ugh the Mac do esn’t limit these 20 co lo rs, even Mac browsers that can display 256 co lo rs do n’t offer a lo t mo re co lo r o ptio ns than a PC browser can offer. Can things get mo re limited? They can. To be as standard as po ssible and to utilize the three- number co lo r- co ding scheme efficiently, Web browser designers came up with a palette of 216 co lo rs that yo u, as a Web page creato r, can use safely. That is, with these 216 browse r-safe co lo rs, so metimes called We b-safe co lo rs, yo u can be assured that all Web browsers in the wo rld will display these

      co lo rs pro perly witho ut relying o n disto rting trickery that washes o ut the effect of o ther co lo rs.

      Session 8 — Working wit h Color in Text and Graphics

      105

      Specifying Browser-Safe Colors The browser- safe co lo rs cho sen by browser makers are an even sampling of co lo rs fro m each of the three red, green, and blue RGB co lo rs. The browser- safe co lo rs span the entire 16- millio n co lo r range, taking the sampling of 216 co lo rs, evenly spaced all alo ng the 16- millio n co lo r spectrum. The browser- safe co lo r values appear in Table 8- 1.

      Browse r-Safe Co lo rs

      De cimal

      Hexade cimal Equivale nts

      0

      00

      51

      33

      102

      66

      153

      99

      204

      CC

      255

      FF

      Igno ring the seco nd co lumn fo r a mo ment, if yo u keep the three numeric co lo r co des matched up with the values in Table 8-1, yo ur co lo rs will always be browsersafe. In additio n, the co lo rs that yo u see o n yo ur own browser will always match the co lo rs that every user will see when he o r she lo o ks at yo ur Web page. Therefo re, if yo u specify a green co lo r of 0-153-0, that co lo r appears o n everybo dy’s Web page in the same co lo r intensity, hue, and to ne. ( Keep in mind the RGB o rder in which the first value always determines how much red is in the co lo r, the seco nd determines how much green is in the co lo r, and the third value determines how much blue is in the co lo r.) In o ther wo rds, 0-153-0 is a safe co lo r to use o n yo ur site, as well as fo r text and the graphics yo u create, because that same co lo r will repro duce accurately in all o ther browser windows. Remember that the co lo r intensities increase as the values increase. In o ther wo rds, a red value of 102- 0- 0 will appear much darker than a red value of 255- 0- 0. A red value of 204- 0- 0 will be 20 percent less intense ( that is, 20 percent darker) than the red that 255- 0- 0 pro duces.

      Part I I — Sat urday Morning Session 8

      Table 8 -1

      106

      Sat urday Morning

      Tip

      Most graphics programs t hese days provide you wit h a browsersaf e color palet t e f rom which you can choose when creat ing GI F images, borders, and ot her graphic element s you might creat e for your Web pages. I nst ead of knowing t he color codes, you can just point - and- click on t he browser- saf e colors provided.

      The seco nd co lumn in Table 8- 1 lists he xade cimal equivalents fo r the decimal numbers. A hexadecimal number ( also called a he x number) is a number based o n the base- 16 numbering system as o ppo sed to the usual base- 10, o r decimal number system, that everybo dy learns as a child. Hexadecimal numbers range fro m 0 to F because, after the number 9, the numbering system co ntinues A, B, C, D, E, and F ( lowercase equivalents are o kay) . The bo tto m line is that every decimal number has a hex number equivalent that must be used in yo ur HTML co de. Fro m Table 8- 1, yo u can see that 204 is the same as the CC hex value. Therefo re, if yo u represent the co lo r co de of 204- 51- 153, yo u can also specify the number using hex values such as CC- 33- 99. Fro m the CC, yo u know that a hex number is being used, but if the numeric value do es no t include any hex values that use letters, yo u wo n’t know if the value is suppo sed to be hex o r decimal. Therefo re, a sho rtcut exists in HTML that lets yo u specify hex values witho ut any redundancy o r co nfusio n to the decimal equivalents. Begin all hex values with a po und sign ( #) and do no t use the embedded dashes. Therefo re, #CC3399 ( o r #cc3399) is the same hex value fo r the co lo r co de CC-33-99 ( which is the same as 204-51-153 decimal) . What do es all this mean? When yo u cho o se co lo rs fro m a graphics pro gram, yo u will pro bably be able to po int to the co lo r yo u want o r enter decimal values fo r the red, green, and blue co mbinatio ns. But when co ding HTML, yo u’ll enter the hexadecimal value to represent yo ur Web page’s co lo rs.

      Never

      Never use nonbrowser- saf e colors. Act ually, you can use any color you want f rom t he 1 6 - million color palet t e, but be warned t hat your page may look ent irely dif f erent f rom what you expect because of t he color subst it ut ions t hat browsers will surely make. To be saf e, st ick t o t he browser- saf e colors.

      The big 1 6 colors If yo u limit yo urself to o nly 16 co lo rs, and that is truly limiting, HTML has assigned names to the 16 mo st co mmo n co lo rs of the PC platfo rm. ( The PC was cho sen as a least- co mmo n- deno minating system.) Altho ugh I canno t show yo u the actual 16 co lo rs o n the pages of this bo o k, Table 8- 2 lists the HTML names fo r these 16 co lo rs, alo ng with their hex equivalents.

      107

      Session 8 — Working wit h Color in Text and Graphics

      Table 8 -2 16 Co mmo n Co lo rs Yo u Can Re fe re nce by Name

      Hexade cimal Value

      HTML Color Name

      Hexade cimal Value

      Aqua

      #00FFFF

      Navy

      #000080

      Black

      #000000

      Olive

      #808000

      Blue

      #0000FF

      Purple

      #800080

      Fuchsia

      #FF00FF

      Red

      #FF0000

      Gray

      #808080

      Silver

      #C0C0C0

      Green

      #008000

      Teal

      #008080

      Lime

      #00FF00

      White

      #FFFFFF

      Maro o n

      #800000

      Yellow

      #FFFF00

      To use o ne of the 16 co lo rs, yo u can specify the name in any tag that accepts a hexadecimal co lo r value instead of using the hex value. The fo llowing tag changes the backgro und to teal:

      If yo u misspell a co lo r in the tag, the browser will substitute a co lo r of its own cho o sing.

      What about t hose nonbrowser-safe colors? Altho ugh yo u’ve displayed images with far mo re than 216 co lo rs and things seemed o kay, when mo re than the browser-safe co lo rs appear, yo ur browser so metimes plays a trick o n yo u to make yo u think that yo u are seeing mo re co lo rs than are actually po ssible. The browser dithe rs the co lo r by co mbining two o r mo re browser-safe co lo rs. If yo u magnify the screen, yo u see that the co lo rs are actually co mbinatio n pixels. At no rmal viewing levels, yo u do no t see that the co lo rs fo rm simply because two different co lo rs are side-by-side. So , yo u may wo nder why yo u simply do n’t let the browsers dither whatever co lo rs yo u uplo ad. One pro blem is that dithering pro duces impure co lo rs. That deep-o cean, squid-ink purple co lo r is no t really the co lo r yo u sent; instead, it is a bunch of tiny co lo r co mbinatio ns. The image with the dithered co lo rs will never lo o k as go o d as it wo uld lo o k if the browser displayed the actual, real co lo r sent to it.

      Part I I — Sat urday Morning Session 8

      HTML Color Name

      108

      Sat urday Morning

      Even tho ugh dithering often go es unno ticed, and clear pho to s appear o n yo ur Web page in spite of it, yo u need to stick with the browser- safe co lo rs when yo u co ntro l the co lo rs yo u pick fo r text, lo go s, and GIF images. The mo re dithering that takes place o n yo ur Web page, the mo re grainy the page appears. Even if the user do esn’t no tice it, a Web page with dithering shown next to the same no ndithered Web page is less appealing. Therefo re, when yo u cho o se co lo rs fo r yo ur site, o n the items that yo u create and add to yo ur page, yo u sho uld use o nly the 216 browser- safe co lo rs.

      Not e

      Browsers rarely dit her background colors. A background image can consume t he ent ire background of a Web sit e. Somet imes, a background may only be a single solid color. Dit hering would be apparent on such a large colored image; t herefore, most browsers subst it ut e a close browser- saf e color for t he nonbrowser- saf e color t hat you select .

      Adding Color t o Text and Backgrounds All that theo ry is wo rthless if yo u do n’t see the practical use of co lo r co des. Actually, applying the co lo r co des is simple using HTML co de. Yo u can co lo r text, backgro unds, and o ther Web page elements using the hex co des. The o nly pro blem is lo cating the hex value of the co lo r yo u want, but again, mo st graphics pro grams display browser- safe co lo r palettes now with the hex equivalents. Suppo se yo u want to make the text in yo ur entire Web page the highest intensive, o r brightest, green po ssible. Yo u can add the text= attribute to the tag as fo llows:

      As wit h many at t ribut es, you’ll of t en see t he hex value enclosed wit hin opt ional quot at ion marks. Not e

      The text= attribute changes all the text o n the Web page. To change o nly specific text, use the color= attribute inside a tag. The fo llowing co de displays the middle wo rd ( which is red) in red:

      This text has a red word inside it.

      The tag overrides any tag in effect.

      Session 8 — Working wit h Color in Text and Graphics

      109

      If yo u want to change the backgro und co lo r of yo ur Web page, use the

      bgcolor= attribute inside the tag. To create a blue backgro und fo r yo ur Web page, o n to p of which all subsequent text will appear, yo u co de the tag as fo llows:

      REVI EW 쐌 쐌 쐌 쐌

      Only a limited number of co lo rs are available to all Web users. All Web co lo rs are fo rmed by co mbining red, green, and blue. Co lo r co des represent the 16 millio n co lo rs po ssible o n to day’s co mputers. Graphics pro grams often eliminate the need fo r yo u to lo cate a co lo r co de, but yo u still must specify the hex number when yo u write HTML co de, with 16 exceptio ns.

      QUI Z YOURSELF 1.

      What do es RGB stand fo r? ( See “ Co lo r Co des and Palettes.” )

      2.

      How many co lo rs can an 8- bit graphics card display at o ne time? ( See “ Browser- Safe Co lo rs.” )

      3.

      What is the hexadecimal equivalent to the fo llowing decimal co de: 204- 0- 51? ( See “ Specifying Browser- Safe Co lo rs.” )

      4.

      True o r False: Yo u can specify the 216 browser- safe co lo rs by name inside co mmand tags. ( See “ The Big 16 Co lo rs.” )

      5.

      What do es the browser do when it receives a no nbrowser-safe co lo r ( assuming the user’s graphics card is an 8-bit card and 256 co lo rs already appear o n the screen) ? ( See “ What Abo ut Tho se No nbrowser-Safe Co lo rs?” )

      Part I I — Sat urday Morning Session 8

      Tip

      Generally, light backgrounds wit h darker t ext are more readable t han dark backgrounds wit h light er t ext . When in doubt , hardly anyt hing works bet t er t han t he st andard whit e Web page background.

      SESSI ON

      9 Text and Graphics Organizat ion

      Session Checklist ✔ Align an image’s surro unding text ho rizo ntally and vertically o n the Web page ✔ Add spacing aro und images and create yo ur own ho rizo ntal rules ✔ Use graphics in headlines and place yo ur own images o n the backgro und of yo ur Web pages

      I

      n the past few sessio ns, yo u’ve seen how to place text and yo u’ve seen how to place graphics o n yo ur Web pages. This sessio n shows yo u how to co mbine text and graphics o n a Web page to pro duce effective presentatio ns of yo ur

      Web co ntent.

      Aligning I mages and Text Co nsider the fo llowing HTML co de. The Web page that co ntains this HTML co de displays text, a graphic image next, and then mo re text. The image, o bvio usly, must appear so mewhere in the middle of the text. The questio n is how will the text surro und the image? Will the text wrap aro und the image o r will the three

      112

      Sat urday Morning

      areas — the two text areas and the image area — co mprise three distinct bands o n the Web page?

      When a Web page combines text and graphics, the placement and alignment of the image determines where the image falls in relation to the surrounding text.

      The image can fall any number of places in relation to the text. You have full control, through HTML, on the alignment of the image and text.

      Figure 9- 1 shows the Web page that results fro m this HTML co de. As yo u can see, by default, the page co ntains three distinct bands: the first text, the image, and the final text. Only a small po rtio n of the text resides o n the same line as the figure.

      Figure 9-1 By de fault, yo ur image s and te xt co nsume diffe re nt are as of the We b page.

      Session 9 — Text and Graphics Organizat ion

      113

      The three separate areas appear because of the paragraph tags. If yo u remove the paragraph tags, things can get messy depending o n the browser. Witho ut the paragraph tags separating the figure fro m the surro unding text, the figure go es inline with the text and falls in the middle of the text witho ut any pro per line breaks.

      Horizont al image alignment

      The align=left and align=right attributes align the graphic image on the page. In addition, align=left and align=right affect how the image adjusts to surrounding text. That is, if you use the align=left or align=right attribute in the tag, subsequent text appears to the left or right of the image.

      Not e

      Remember t hat t he align=left and align=right at t ribut es det ermine how subsequent t ext appears, not t ext already displayed. Therefore, all previous t ext t hat appears in your HTML code displays on t he page in it s normal fashion. When t he t ag appears wit h an align=left or align=right at t ribut e, any remaining t ext on t hat page begins next t o t he image.

      The fo llowing co de is identical to what yo u have seen in the previo us example except that the tag includes the align=right attribute. This means that the image, no t the text, aligns ho rizo ntally to the right side of the window and the text appears to the left of that image, as Figure 9- 2 shows. The text that fo llows the tag appears to the left of the image; this text is no t extremely lengthy, but as yo u can see fro m the figure, it appears o n the same ho rizo ntal area as the image and do es no t wait to appear after the image downlo ads. If yo u include the align=left attribute, the image will appear o n the window’s left side.

      When a Web page combines text and graphics, the placement and alignment of the image determine where the image falls in relation to the surrounding text.

      The image can fall any number of places in relation to the text. You have full control, through HTML, on the alignment of the image and text.



      Part I I — Sat urday Morning Session 9

      The tag supports the align= attribute that you learned about in Session 7.

      114

      Sat urday Morning

      Figure 9-2 The align= attribute can de te rmine o n which side of the image the te xt appe ars.

      Vert ical image alignment The text that appears to the left and right of the image in Figure 9- 2 lo o ks so mewhat strange because of a few reaso ns: The text is no t lo ng eno ugh to fill the area next to the image, and the text aligns at the to p of the image and do es no t rest o n the image’s baseline, no r is it centered to the image’s vertical area. The tag suppo rts three vertical alignment attributes with which yo u can better align the image to the text. Yo u can specify align=top ( the default) ,

      align=middle, o r align=bottom to determine how the image aligns with the base of the text. Figure 9- 3 shows the result of all three vertical alignment attributes by showing an image aligned to the to p of the text’s baseline, the middle, and the bo tto m of the text’s baseline, acco rding to the fo llowing HTML co de:

      Aligns with the align=top attribute.



      Session 9 — Text and Graphics Organizat ion

      115

      Aligns with the align=middle attribute.

      Aligns with the align=bottom attribute.

      Part I I — Sat urday Morning Session 9

      Figure 9-3 The image is aligne d with the te xt’s ve rtical base line in thre e diffe re nt ways.

      Never

      Never mix an align=left or align=right at t ribut e wit h one of t he vert ical alignment at t ribut es. HTML goes by only t he f inal align= at t ribut e t hat you specif y in an t ag list . I f you want t he image t o align on t he lef t or right side of t he t ext when you use one of t he vert ical alignment at t ribut es, ent er t he t ext before t he t ag. Ent er t he t ext af t er t he t ag if you want t he image t o appear t o t he lef t of t he t ext . The t ext precedes t he image placement , hence t he t ext appears t o t he right of t he image.

      116

      Sat urday Morning

      Tip

      The
      t ag support s clear=left, clear=right, and clear=all at t ribut es t hat enable you t o st op or change t he alignment of an image f rom t hat point forward in t he t ext . I n ot her words, if you lef t - align an image so t hat t he subsequent t ext appears t o t he right of t he image, place t he
      at t he point where you want t he t ext t o st op appearing next t o t he image. The t ext will st op appearing unt il t he ent ire lef t margin is clear of t he image. I f you specif y
      , t he subsequent t ext in t he HTML page st ops appearing unt il t he right margin is f ree of t he image. The
      t ag resumes t he display of t ext once bot h margins are clear of any images.

      A special vertical alignment attribute, align=absmiddle, aligns an image in the very center of a ho rizo ntal line of o ther graphics and text. If yo u want an image to appear in the center of its surro unding images and text, instead of aligning the image o nly to text alo ne, use align=absmiddle.

      Spacing I mages and Creat ing Horizont al Rules Several metho ds enable yo u to co ntro l exact spacing between images, and the next sectio n explains o ne of the easiest ways. In additio n, yo u can create yo ur own images that beco me ho rizo ntal rules to eliminate the bo ring gray ho rizo ntal rule that appears as a result of the tag that yo u learned abo ut in Sessio n 6.

      I ncreasing image space The tag suppo rts the hspace= attribute that determines how much blank space, in pixels, an image co ntains o n its left and right sides. The vspace= attribute co ntro ls blank space at the to p and bo tto m of an image. The best way to learn these spacing attributes is to see them in actio n. Figure 9-4 shows the same image displayed three times with text appearing to the right of the image in each case. Listing 9- 1 co ntains the co de necessary to pro duce Figure 9- 4. The first image shows the text as it appears with no added spacing specified aro und the image. The seco nd image appears with ho rizo ntal space added to the image. The final image appears with vertical space at the to p and bo tto m of the image.

      117

      Session 9 — Text and Graphics Organizat ion

      Part I I — Sat urday Morning Session 9

      Figure 9-4 The e ffe ct of adding e xtra ho rizo ntal and ve rtical space aro und an image

      Listing 9 -1 Incre asing the blank pixe l are a o n an image ’s side s

      The image aligns with no extra space around the image. Notice the image appears to the left of the text due to the image’s align= attribute and no extra space appears on the side of the image. The image contains micro-spacing on its sides automatically.



      Co ntinue d

      118

      Sat urday Morning

      Listing 9 -1

      Co ntinue d

      The image aligns with extra space around the image. Notice the image appears to the left of the text due to the image’s align= attribute and extra space appears on the sides of the image. The image contains micro-spacing on its sides automatically.



      The image aligns with no extra space around the image. Notice the image appears to the left of the text due to the image’s align= attribute and extra space appears on the top and bottom sides of the image. The image contains micro-spacing on its sides automatically and vspace= adds additional space on the top and bottom of the image.



      Creat ing your own horizont al rules If yo u want to spruce up the gray ho rizo ntal rules that appear as a result of the

      tag, yo u can create yo ur own. Feel free to create all the ho rizo ntal rules yo u want. The ho rizo ntal rule files sho uld be GIF images. The o nly thing yo u need to remember when using GIF files as ho rizo ntal rules is that yo u sho uld perfo rm an align=center co mmand befo re using yo ur own rule images so that text do es no t flow o ddly aro und a graphic ho rizo ntal rule that’s suppo sed to be separating text sectio ns.

      Use graphic horizont al rules t hat repeat a simple pat t ern t o creat e separat ing rules t hat do not dist ract f rom t he t ext and, more import ant ly, t he images on your Web page. Tip

      Just abo ut any graphics pro gram will create fancy ho rizo ntal rules with little effo rt o n yo ur part. So metimes, a simple co lo red line, three o r fo ur pixels wide, makes the perfect ho rizo ntal rule fo r a page. Altho ugh the standard ho rizo ntal rule that appears because of the tag wo rks well fo r just abo ut any page of any design, unique rules can help distinguish yo ur Web page.

      Session 9 — Text and Graphics Organizat ion

      119

      Using Headline and Background I mages Two additional uses of graphics are their placement in headlines ( which are covered in Session 5) , such as banner ads, and as background images produced from an enlarged version of a graphic image. The next two sections discuss these two additional uses.

      When yo u use an image in a headline, as yo u might do when placing a banner advertisement at the to p of yo ur Web page, be sure to enclo se the image inside the page’s tag. Co nsider the fo llowing co de:



      A headline image can appear bet ween any of t he headline t ags, t hrough . The headline t ags are explained in Session 5 . Not e

      Figure 9- 5 shows the result of placing an image inside headline tags. Altho ugh the headline tags are no t required fo r the image to appear befo re the text, since yo u can easily use an tag inside the Web page bo dy to display an image befo re text begins, the headlines enable yo u to easily maintain the headline placement later. Yo u can add additio nal headline levels o r change the headline level of the image witho ut having to restructure the bo dy of yo ur page.

      Background images As yo u learned in Sessio n 5, the bgcolor= attribute of the tag co lo rizes yo ur Web page backgro und. Yo u are no t limited to single co lo rs that the tag provides. Yo u can place yo ur own image o n the backgro und of yo ur Web pages. Use the background= attribute inside the tag using this fo rmat:

      Part I I — Sat urday Morning Session 9

      Headline graphics

      120

      Sat urday Morning

      Figure 9-5 Image s wo rk we ll inside he adline s.

      No t every image wo rks well as a backgro und fo r yo ur Web page. Keep the fo llowing in mind:

      쐌 Do no t make yo ur backgro und image stro nger than yo ur Web page. If the backgro und includes rich co lo rs and crisp lines, the text and graphics that yo u intend to place over the image will be less no ticeable. The backgro und is exactly that: a backgro und.

      쐌 A light backgro und is almo st always preferable to a dark backgro und. Several exceptio ns to this exist, however. Black actually makes a go o d backgro und fo r so me text. Yo u will have to experiment.

      쐌 Yo u can create yo ur own backgro und images. All yo u need to do , if yo u create a backgro und that co ntinually repeats a pattern, is create o nly the small, single instance of the pattern, and the browser will repeat that image until the Web page backgro und is full.

      쐌 Even tho ugh the image repeats, the browser o nly has to lo ad the image o ne time. Therefo re, a backgro und takes o nly as lo ng to lo ad as the single pattern image takes to lo ad.

      쐌 When yo u create yo ur backgro und’s pattern, make sure that the pattern has no bo rder.

      쐌 Your background image patterns can be large, but make sure the pattern fits well within a small browser. Then, when the image repeats, even inside the small browser, at least two full images will appear in the browser background.

      Session 9 — Text and Graphics Organizat ion

      121

      Figure 9- 6 shows an effective backgro und image that is rather different fro m the typical repeated pattern image. The image repeats o nly o nce, but the do uble image enclo ses the rest of the page fairly effectively. ( On large mo nito rs powered by high- reso lutio n graphic adapters, the image repeats three o r mo re times.)

      Part I I — Sat urday Morning Session 9

      Figure 9-6 Whe n a backgro und image re pe ats, the lo ad time take s o nly as lo ng as the single image take s to lo ad.

      REVI EW 쐌 Yo u can align yo ur images pro perly with text and with o ther images o n yo ur Web page.

      쐌 Extra space aro und so me graphics often set apart the image fro m o ther elements o n yo ur Web page.

      쐌 Yo u can create yo ur own ho rizo ntal rule images with just abo ut any graphics pro gram when the no rmal gray ho rizo ntal rules are no t eno ugh.

      122

      Sat urday Morning

      쐌 Headline graphics, such as banner ads, can be enclo sed inside tags. 쐌 A backgro und image repeats until yo ur entire Web page backgro und is filled.

      QUI Z YOURSELF 1.

      Which attributes align graphics with text o n yo ur Web page? ( See “Aligning Images and Text.” )

      2.

      What happens if yo u mix vertical and ho rizo ntal alignment attributes? ( See “ Vertical Image Alignment.” )

      3.

      How can yo u vertically center an image o n an area of the Web page that co ntains o ther images and text? ( See “ Vertical Image Alignment.” )

      4.

      Which attributes increase the ho rizo ntal and vertical spacing of blanks aro und yo ur Web page? ( See “ Increasing Image Space.” )

      5.

      True o r False: A light backgro und typically, but no t always, wo rks best with light text in the fo regro und. ( See “ Backgro und Images.” )

      SESSI ON

      10 Hyperlinks Connect t he Web

      Session Checklist ✔ Master URL basics ✔ Specify hyperlinks to o ther Web pages ✔ Insert thumbnail pictures in hyperlinks ✔ Specify hyperlinks within yo ur own Web pages with bo o kmarks ✔ Distinguish between base URLs and relative URLs

      I

      n this sessio n, yo u learn how to create the links, also called hyperlinks, which enable yo ur Web page users to jump to and fro m yo ur page to o ther pages of info rmatio n o n the Web. Yo u also learn how to create bo o kmarks that allow

      users to jump to and fro m areas of interest o n the same Web page. It is the hyperlink that made HTML such a required fo rmat fo r Web pages. Hyperlinks are simple because of the ancho r tag, , that makes the links po ssible.

      URL Basics As yo u know, a URL ( Unifo rm Reso urce Lo cato r) is the Web address of a specific do cument. URLs no t o nly po int to Web pages, they also might po int to o ther items

      124

      Sat urday Morning

      such as graphic images. Therefo re, if a Web page co ntains a JPEG, and yo u know the name of that JPEG, yo u can type the URL fo r that page fo llowed by /item.jpeg/ and yo ur browser will display that figure inside yo ur browser window.

      Never leave a space bet ween t he t ag and t he closing anchor t ag. Ot herwise, a small blank space, called a t ick, might appear on your Web page bet ween t he image and t he next it em on t he page.

      Never

      The standard fo rmat of URLs is:

      protocol://site address/directory/filename Mo st Web pages co ntain a ho me page, named index.html, which appears by default when a browser po ints to that address. Therefo re, in mo st cases, the fo llowing URLs are equivalent:

      http://www.goodsite.com/index.html/ http://www.goodsite.com/ The pro to co l is often http that represents a Web page, but the pro to co l can also be any of the pro to co ls listed in Table 10- 1.

      Table 1 0 -1 Pro to co l Value s

      Protocol

      De scription

      file

      A file o n the lo cal co mputer

      ftp

      File transfer pro to co l fo r file downlo ads

      http

      Transfer pro to co l fo r Web pages

      mailto

      A Simple Mail Transfer Pro to co l ( also known as SMTP) window fo r sending e- mail

      nntp

      A specific newsgro up article

      news

      A newsgro up

      By far, the mo st co mmo n pro to co l used is the http pro to co l that represents o ther Web pages. Many of the pro to co ls require special handling.

      Session 1 0 — Hyperlinks Connect t he Web

      125

      I n t he next session, you learn how t o use t he mailto prot ocol t o embed mail links inside your page. Cross-Ref

      Specifying Hyperlink Tags The primary metho d fo r representing a hyperlink is to use the tag with the

      href= attribute. The tag includes the URL fo r the hyperlinked Web page. The a in the tag means ancho r. A hyperlink’s end po ints are known as ancho rs, hence the tag. The tag also requires an end tag, . Here is the basic fo rmat of the

      tag: hot spot text The reference inside the tag represents the hyperlink, also known as the ho t spo t ( o r the ancho r) , that the browser jumps to when the user clicks o n the

      ho t spo t ( o r hyperlink) text. The fo rmat’s ho t spo t te xt represents the text that appears in yo ur Web page that the user clicks o n to move to that new ancho r. The fo llowing co mmand directs the user to Micro soft’s ho me page:

      Check for a new Windows release When the browser gets to this co de, the browser displays the text, Check for a new Windows release, and the browser turns that text into a hyperlink by typically underlining that text. When the user po ints to that hyperlink, the user’s mo use po inter often turns into a po inting hand to indicate that the text represents a link and is no t simply regular underlined text.

      Never underline regular, nonhyperlinked t ext because users get conf used when some underlined t ext indicat es a hyperlink and ot her underlined t ext does not . Never

      Part I I — Sat urday Morning Session 1 0

      Never

      Never use t he file prot ocol t o link t o a f ile on your own comput er unless you use a reliable and fast server t hat is up 2 4 / 7 ( 2 4 hours a day, 7 days a week) . I f , for example, you link t o a f ile on your home comput er, you cannot ensure t hat your comput er will be logged ont o t he I nt ernet all t he t ime, and several users at once will slow t he syst em and prot ocol t o a halt .

      126

      Sat urday Morning

      Not e

      Browsers dif f er in how t hey display hyperlinks. I n addit ion, t he user might t urn of f t he underlining of hyperlinks. For example, in Windows 9 x running I nt ernet Explorer 4 and higher, users can, at t he operat ing syst em level, display hyperlinks t hat appear in a new color but not underlined unt il t he user point s t o t he hyperlink, at which t ime Windows underlines t he link. Using st yle sheet s ( see Session 2 0 ) enables you t o t urn of f t he default underlining beneat h links complet ely.

      The lo catio n of the tag inside surro unding text determines exactly where the hyperlink falls. In o ther wo rds, o nly the text indicated as the ho t spo t text is the actual hyperlink. Figure 10- 1 shows how each of the fo llowing three similar ho t spo ts differ:



      Your version of Windows determines whether or not you have Internet Connection Sharing.
      Check for a new Windows release



      Your version of Windows determines whether or not you have Internet Connection Sharing.
      Check for a new Windows release.



      Your version of Windows determines whether or not you have Internet Connection Sharing.
      Check for a new Windows release. In the first sectio n in Figure 10- 1, the hyperlink is “ Check fo r a new Windows release” because this phrase is indicated as the ho t spo t text in the first example above. The seco nd hyperlink is “ Windows,” and the third hyperlink is “ Windows

      Session 1 0 — Hyperlinks Connect t he Web

      127

      release,” since these paragraphs serve as the ho t spo ts in the seco nd and third examples above.

      Part I I — Sat urday Morning Session 1 0

      Figure 10-1 The ho t spo t te xt de te rmine s what the use r clicks.

      Not e

      Many browsers display an unclicked link ( called an unvisit ed link) in one color, a clicked link ( called a visit ed link) in anot her, and a link- in- progress ( a link you’ve clicked but for which t he page has not opened yet , called an act ive link) in a t hird color. These colors inform t he user of which links have been visit ed.

      Text is no t the o nly item yo u can place inside the ancho r tags. Yo u can also place graphic images. The sectio n o n thumbnail pictures discusses the use of images as hyperlinks.

      Never

      Never omit t he closing t ag even t hough some HTML programmers do. Talk is under way bet ween some browser makers t o require t he end t ag, alt hough t o do so will make many exist ing Web pages t hat don’t specif y t he t ag work improperly.

      128

      Sat urday Morning

      Cont rolling hyperlink colors As mentio ned in the previo us sectio n, Web page hyperlinks change co lo rs to indicate whether o r no t the user has selected tho se links yet. Yo u have the o ptio n of leaving the cho ice of link co lo rs up to the user’s browser o r specifying the hyperlink co lo rs yo urself. ( The co lo rs that change as the user visits links are called link re nde rings. )

      The fo llowing attributes specify co lo rs fo r the ancho r’s links:

      link=

      Determines the co lo r of the unvisited hyperlink

      alink=

      Determines the co lo r of the active link, the link that the user has clicked but who se page has no t yet o pened

      vlink=

      Determines the co lo r of the visited link, a link that the current user has visited

      Suppo se yo ur user visits yo ur Web site fo r the first time. All the hyperlinks will be o ne co lo r, the link= attribute’s co lo r. When the user clicks a link, that link changes to the alink= attribute’s co lo r until the link lo ads. Then, when the user returns to yo ur page, the link appears in the vlink= attribute’s co lo r. If yo u have no t specified o ne o r mo re of the co lo rs, the user’s browser will determine the links’ co lo rs. The co lo r yo u specify can be a hexadecimal co lo r co de o r o ne of the 16 co lo r values suppo rted by name as explained in Sessio n 8.

      Never

      Never st ray t oo far f rom t he browser’s default hyperlink color scheme or you will conf use t he users. Some Web sit es t hat have ext remely dif f erent t hemes, such as a science f ict ion- based Web sit e, might work well wit h a new set of hyperlink colors, but generally, t he browser’s default colors are t he ones t hat you should st ick wit h.

      Specifying hyperlink t it les Use the title= ( o r title) attribute with the and tags when yo u want a po p- up descriptio n, called a to o l tip, to appear when the user po ints the mo use to the hyperlink. Witho ut a title, the to o l tip will be the URL that the link references. Here is an example of the title= attribute:

      To mail letters Figure 10- 2 shows such a title at a hyperlink. After a mo ment, the hovering mo use curso r pro duces the title text.

      Session 1 0 — Hyperlinks Connect t he Web

      129

      Part I I — Sat urday Morning Session 1 0

      Figure 10-2 The addre ss info rmatio n to o l tip appe ars whe n the mo use po ints to the hype rlink.

      Opening a new window When the user clicks o n the hyperlinks yo u’ve seen so far in this sessio n, the user’s browser window changes to the page of the new link. If, instead, yo u want to o pen a new window when the user clicks yo ur hyperlink’s ancho r tag, use the

      target=”_blank” attribute. The o riginal window, such as yo ur ho me page, will remain o pen, and the new, seco nd window will co ntain the hyperlinked Web page. The fo llowing line o pens the image in a new window:

      No rmally, the target= attribute suppo rts the use of frames that yo u’ll learn abo ut in Sessio n 18, but the target=”_blank” attribute wo rks with o r witho ut frames and provides a way fo r yo u to o pen a new window to display the target of the hyperlink. The new window po ps up o n to p of the user’s window so that bo th co ntain info rmatio n.

      130

      Sat urday Morning

      Specifying t he t ab order of hyperlinks The ancho r tag suppo rts the tabindex= attribute, which determines the tab o rde r of the links o n the Web page. Suppo se a Web page co ntains 20 hyperlinks. The user can press the Tab key to highlight each link in successio n and press Enter when the link that the user wants to see is highlighted. This way, the user can view links with o nly a keybo ard instead of using the mo use. The value that fo llows the

      tabindex= attribute must be a po sitive number, beginning at 1, that determines the o rder of the links highlighted as the user presses Enter. No two numbers can be the same thro ugho ut a page’s links. The fo llowing statement ensures that the link is the first thing the user tabs to :

      Tip

      WebTV I nt ernet users of t en use keyboard commands inst ead of mouse- based commands. I n addit ion, when you add t he keyword selected t o one of your page’s links, t hat link will be t he default link when t he WebTV user f irst views your Web page.

      The pro blem with the tabindex= attribute is that tabindex= is no t suppo rted by all browsers. The tabindex= attribute is a new feature of HTML 4.01. No pro blem o ccurs if the user’s browser fails to reco gnize the tabindex= attribute. If the browser do es no t reco gnize the attribute, the user’s tab o rder will be the default tab o rder generated by the browser.

      Thumbnail Pict ures As no ted earlier, yo u can place graphic images inside yo u ancho r tags. When yo u enclo se an image instead of text between the and tags, the image beco mes the ho t spo t that pro duces the hyperlink when the user clicks the image. Typically, the o nly hint that the image is a hyperlink is the co ntext of the image o n the page ( such as a po inting finger that indicates a co ntinued tho ught) and the curso r that changes to the po inting hand shape when the user hovers the mo use po inter over the image.

      Not e

      I f t he hyperlink image has a border set t o a value great er t han one pixel, t he border color will be t he same color as t he link= at t ribut e color in ot her hyperlinks. Such a border adds anot her clue t hat t he image act s as a hyperlink.

      131

      Session 1 0 — Hyperlinks Connect t he Web

      A thumbnail image is a small, fast- lo ading versio n of a larger picture. Yo u can place a thumbnail image o n a Web page with any image tab and then make the thumbnail a link to the larger versio n. The fo llowing co de turns a small thumbnail image into a link to a larger image:

      Figure 10- 3 shows what happens when the user clicks a thumbnail image o n a Web page that uses the target=”_blank” attribute: The hyperlink pro duces the full- sized image in a new window. By o pening the larger image in a separate window, the user can go ahead and visit o ther links while the image lo ads in its own window.

      Thumbnail

      Larger image window

      Figure 10-3 The thumbnail give s the use r a pre vie w of the large r image.

      Part I I — Sat urday Morning Session 1 0



      132

      Sat urday Morning

      Tip

      Always specif y t he f ile size if a hyperlink is going t o load an ext remely large graphic image or Web page. You might want t o add a t ool t ip or include t ext below t he image t hat specif ies t he f ile size, such as Beautiful car (140K).

      I nsert ing Bookmarks t o Links on t he Same Page Bo o kmarks, also known as marke rs o r fragme nts, are hyperlinks to areas o n the

      same page instead of a different Web page. One of the mo st useful places to insert a bo o kmark is at the bo tto m of a lo ng Web page. With the bo o kmark at the bo tto m of the page, the so urce wo uld, when clicked, return the user to the to p of the page ( the so urce ) . Bo o kmarks, unlike regular links, never send the user to a different page, o nly to a destinatio n o n the current Web page. The bo o kmarks eliminate the need fo r scro lling back to the to p of a lo ng Web page. Yo u might include a bo o kmark that reads, Go to Top of Page, and when the user clicks this bo o kmark, the browser jumps to the to p of the page, eliminating the user’s need to scro ll up a lengthy page. Yo u must use two ancho r tags to create a bo o kmark link — the bo o kmark’s so urce tag and the bo o kmark’s destinatio n tag. The destinatio n tag uses the name= attribute to determine the hyperlink’s destinatio n. In such a tag, yo u co mpletely replace the href= attribute with the name= attribute, as in the fo llowing example that names the current spo t, the to p of the Web page, to p:

      Later, o ne o r mo re regular links, the destinatio n links, might appear so that when the user clicks the link, the browser scro lls back to the to p of the page. If yo u type text between a bo o kmark’s destinatio n ancho r tag, the text appears o n the screen but will no t be underlined o r co lo red as it wo uld be if the tag indicated a hyperlink. Therefo re, the fo llowing creates a destinatio n bo o kmark named PeachPit and displays the text Peaches o n the screen:

      Peaches The reaso n that the bo o kmark is no t indicated by co lo ring o r underlining is that the bo o kmark is simply a tag that defines the lo catio n of a bo o kmarked link. This lo catio n, peachPit, is where the browser will jump to when the user clicks a bo o kmark so urce link that sends the browser to this destinatio n.

      Session 1 0 — Hyperlinks Connect t he Web

      133

      Altho ugh yo u can co mbine name= and href= in the same tag, do ing so can co nfuse yo u later when yo u maintain the page. Yo u can mo re easily maintain two separate tags fo r the two different kinds of links. Thro ugho ut yo ur Web page, o ne o r mo re ancho r tags, the destinatio n tags, can reference that so urce bo o kmark. When the user clicks o ne of these references, the Web browser jumps to the bo o kmark specified. To set up a link that directs the browser to the bo o kmark, create an ancho r tag using the no rmal href= attribute The fo llowing line creates a po inter to the bo o kmark named to p:

      Go to top of page Altho ugh this destinatio n link lo o ks like a regular hyperlink, with the appro priate co lo r and link underline, the user’s screen will no t lo ad a new Web page; instead, it will jump to the to p of the current page where yo u’ve specified a bo o kmark such as the fo llowing:

      Never

      Never begin a hyperlink ’s t ext wit h t he phrase, “ Click here, ” as in “ Click here t o see a pict ure. ” Such links are considered redundant at best and show a lack of prof essionalism in a sit e ’s creat ion. You can assume t hat your users underst and simple Web operat ions, such as hyperlinks. Maint ain more prof essional links, such as “ Mary’s phot o, ” inst ead of wordy ones, such as “ Click here t o see Mary’s phot o. ”

      Absolut e URLs versus Relat ive URLs No t every hyperlink requires a co mplete Web address. HTML suppo rts bo th base URLs ( also called abso lute URLs, tho se URLs with the co mplete pathname, such as

      http://www.myWeb.com/photos.html/) and re lative URLs ( such as photos.html) . The difference is that yo u can specify a relative URL as lo ng as the link resides in the same directo ry as the current Web page. Suppo se yo ur Web page resides at http://www.myWeb.com/ and is named

      index.html, which implies that the full path to yo ur Web page is this: http://www.myWeb.com/index.html/

      Part I I — Sat urday Morning Session 1 0

      but insert a po und sign ( #) befo re the bo o kmark’s name.

      134

      Sat urday Morning

      As lo ng as photos.html also resides in the same directo ry as index.html, the fo llowing references are exactly the same:

      http://www.myWeb.com/photos.html and

      photos.html Relative links really do no t lo ad any quicker than abso lute links, but relative links do offer the advantage of being easier to move. If yo ur base directo ry changes, yo u wo n’t have to change any link that is relative based o n yo ur directo ry. Yo u’ll o nly need to change the abso lute URLs that refer to the o ld path.

      Not e

      All t he st andard direct ly t raversal codes work in relat ive URLs, such as t he single dot t hat means current direct ory and t he double dot t hat means t he parent direct ory. The following t ag cont ains a relat ive URL t hat begins t wo direct ories higher t han t he current one:

      REVI EW 쐌 URLs include an item’s pro to co l, which is often http. 쐌 The and end tags specify the ancho r po int of a hyperlink. 쐌 Only rarely will yo u want to change a hyperlink’s co lo r scheme. It’s better to stick with the browser’s default co lo rs.

      쐌 Yo ur page’s hyperlinks can replace the current browser window with a new page o r o pen a new window with the linked page, depending o n the presence of the target=_blank attribute.

      쐌 Thumbnail images are go o d uses of hyperlinks that link to larger images. 쐌 Altho ugh yo u can specify the tab o rder of the links o n a Web page, many browsers do no t suppo rt the tab o rder that yo u request.

      쐌 Relative URLs are quicker to co de than full, abso lute URLs, as well as being easier to maintain.

      Session 1 0 — Hyperlinks Connect t he Web

      135

      QUI Z YOURSELF 1.

      Which attribute specifies the hyperlink’s URL? ( See “ Specifying Hyperlink Tags.” )

      2.

      Why is it better no t to use underlines when specifying no nhyperlink text? ( See “ Specifying Hyperlink Tags.” ) What is the difference between a Web page’s unvisited hyperlink, an active hyperlink, and a visited hyperlink? ( See “ Co ntro lling Hyperlink Co lo rs.” )

      4.

      What is the difference between a bo o kmark and a hyperlink? ( See “ Inserting Bo o kmarks to Links o n the Same Page.” )

      5.

      What directo ry do es a relative URL use fo r its base directo ry? ( See “Abso lute URLs versus Relative URLs.” )

      Part I I — Sat urday Morning Session 1 0

      3.

      SESSI ON

      11 E-mail Links, Comment s, and Special Charact ers

      Session Checklist ✔

      Make it easy for users to send you e-mail with e-mail hyperlinks ✔ Add ample comments throughout your HTML code ✔ Use character codes when you want to display special characters on your Web page

      n the previous session, you learned how to set up hyperlinks that jump from page to page and between bookmarks of a current page. One of the protocols you read about was the mailto protocol. In this session, you learn how to use the mailto protocol to set up e-mail links in your Web page, enabling users to send e-mail to you easily. This session then branches off into two new topics. It shows you how to add as many comments as is reasonable to your HTML code to make maintenance easier, as well as how to use character codes to display special characters on your Web page.

      I

      140

      Sat urday Aft ernoon

      Creat ing E-mail Links When you offer your users a chance to give you feedback, you can supply them with a link that opens their default mail system’s new e-mail message window. If you choose not to provide such a simple link, your users probably won’t go through the trouble of contacting you. Consider the Web pages you visit. Are you more likely to send e-mail to someone who supplies only their e-mail address or send e-mail to someone who adds an e-mail link right on the page you are visiting? Without the link, you must type the e-mail address (assuming it appears on the page) or, at best, copy and paste the address into your e-mail program that you must start yourself. An e-mail link both starts the user’s default e-mail program and opens a new message window to make completing and sending the e-mail quick and easy. Uses for e-mail links

      E-mail links on your site are useful for many reasons, including: 쐌 Getting feedback about your site’s usefulness 쐌 Receiving requests for different information on the site 쐌 Contacting a customer service department 쐌 Providing an online employee directory

      Specifying e-mail links

      To specify an e-mail link, simply use the mailto protocol in place of the typical http protocol. The following line adds an e-mail link to a Web page: Customer Service

      The e-mail anchor looks and acts just like other kinds of hyperlinks. The link appears underlined and in the browser’s default link color. (You can override the colors using the link color attributes you learned in the previous session.) When the user clicks the e-mail link, a mail window, such as the one in Figure 11-1, opens. The user can type a subject, a message, and then click Send to get the message to the address you specified in the link.

      Session 1 1 — E-mail Links, Comment s, and Special Charact ers

      141

      The o pe ning of a mail window with a click make s it e asy fo r We b use rs to se nd yo u e -mail.

      Not e

      Ot her mailto prot ocol at t ribut es are somet imes available, such as subject= t hat f ills in t he subject for you, but most browsers do not support t hese opt ions because no indust ry st andard has been agreed upon. Some day, ext ra mailto at t ribut es might become st andard, but it will t ake a while for t he majorit y of users t o updat e t heir browsers. I t is bet t er t o let your users f ill in t he subject and message body t han t o at t empt t o use some of t hese unusual mailto prot ocol at t ribut es.

      Problems rarely, but might, occur if the user does not have an e-mail program set up within the browser’s options. If no e-mail program is set up, the selected mailto hyperlink will produce an error message within the user’s browser as a result of the Web page link. Such an error happens so rarely that you can safely ignore the potential problem; most users have e-mail accounts readily set up for use.

      Part I I I — Sat urday Af t ernoon Session 1 1

      Figure 11-1

      142

      Sat urday Aft ernoon

      Adding Comment s t o HTML Code As you write more HTML code, your Web pages will become larger, making the maintenance of your HTML complicated. One of the best favors you can do for yourself is to add ample comments as you write HTML code. Anot her reason for learning how t o code comment s is t hat more advanced Web page element s, such as JavaScript , require t he use of comment s. Tip

      A comment is a note that you include inside your HTML code. The browser completely ignores comments! Your comment can span 30 lines of HTML code, and the browser gracefully ignores all of the comment’s text. Comments are not browser commands. They are notes for the programmer that explain the HTML code. Some uses for comments are: 쐌 Displaying a list of changes made to the Web page since its original publication to the site, along with the HTML programmers who made those changes. 쐌 Explaining sections of HTML code; when some code or a graphic image name seems to be cryptic, a well-placed comment can explain what the HTML programmer had in mind. 쐌 Executing JavaScript code that can activate your site and make your Web page interactive. 쐌 Reminding you to add certain features that you may have omitted from the early versions of the site. 쐌 Explaining why you used a certain tag when another, more recent tag, may be more acceptable. For example, you may want to explain why you used individual tags and no style sheets if you know your audience generally uses older browsers. 쐌 Commenting out a section of HTML code that you want to hide from the browser, perhaps to test another area of the Web page or to eliminate a new feature for a specified period, at which time you remove the comment. 쐌 Inserting a comment to inform your clients where certain data goes when the client is ready, if you create Web pages for others to use. For example, a comment can inform a client where a new price goes when the price becomes available.

      Session 1 1 — E-mail Links, Comment s, and Special Charact ers

      143

      If you’ve ever written computer programs in a non-HTML programming language, you’ve seen comments before. Comments, like tags, are enclosed by . The HTML code continues immediately after the comment. Consider the following code:

      Often, the names of graphic files are cryptic, but the comment can help clarify the image’s purpose. Doing so at the comment, so close to the image, will keep the HTML programmer from having to maintain a table of image descriptions and filenames displayed on the page. Comments make great holding areas for contact information. The following comment at the top of the HTML code tells subsequent HTML coders where to locate the original page authors:

      144

      Sat urday Aft ernoon

      I nsert ing Special Charact ers on Web Pages When you must display special characters, your browser might interpret those characters as HTML code instead of displayable characters. In addition, some special characters don’t appear on your keyboard. To display special characters, you must use character codes that represent these symbols. For example, suppose you create a Web site that explains how to write HTML code. On such a site, it would be reasonable to assume that the following text may need to appear on the site: Use the paragraph tag,

      , to insert a blank line between paragraphs.

      The problem with such text is that if you embed this inside HTML code, you’ll get results that look something like that in Figure 11-2. The

      , a special character, does not show up because the browser thinks the

      is a tag. The browser, therefore, performs the tag’s purpose instead of simply displaying the tag.

      Figure 11-2 The browse r tho ught that a tag was e mbe dde d in the te xt.

      Not only might you want to display tags themselves on your Web page, but you also may want to display special characters that do not appear on the typical computer keyboard, such as the copyright or foreign currency symbols. HTML supports numerous codes that you can use to represent special characters on your Web page. Table 11-1 lists several of the special characters and the corresponding codes. Although the table is lengthy, spend the rest of this session looking

      Session 1 1 — E-mail Links, Comment s, and Special Charact ers

      145

      through the characters so you know what is available for you to use. To produce the line that included the paragraph tag in the previous example, you could use the greater-than and less-than character codes on the screen like this: Use the paragraph tag,

      , to add a blank line between paragraphs.

      Many of the character codes have an equivalent characte r e ntity (also shown in Table 11-1) that enables you to use a more memorable mnemonic for some of the codes. For example, you can specify è or è when you want to display the small e with a grave accent, è. Table 1 1 -1

      Characte r

      Code

      Characte r Entity



      "

      "

      #

      #

      $

      $

      %

      %

      &

      &



      '

      &

      &

      &




      í

      ¡

      ¡

      ¢

      ¢

      ¢

      £

      £

      £

      ¤

      ¤

      ¥

      ¥

      ¥



      ¦

      &brkbar;

      Part I I I — Sat urday Af t ernoon Session 1 1

      Spe cial Characte r Co de s

      Co ntinue d

      146

      Sat urday Aft ernoon

      Table 1 1 -1

      Co ntinue d

      Characte r

      Code

      Characte r Entity

      §

      §

      §

      ¨

      ¨

      ¨

      ©

      ©

      ©

      ª

      ª

      ª

      «

      «

      «

      ¬

      ¬

      ¬

      ®

      ®

      ®

      ¯

      ¯

      &hibar;

      °

      °

      °

      ±

      ±

      ±

      2

      ²

      ²

      3

      &$179;

      ³

      ´

      ´

      ´

      >

      µ

      µ







      ·

      ·

      &midot;

      ¸

      ¸

      ¸

      1

      ¹

      ¹

      º

      º

      º

      »

      »

      »

      ⁄4

      ¼

      ¼

      ⁄2

      ½

      ½

      3

      ⁄4

      ¾

      ¾

      ¿

      ¿

      ¿

      1

      1

      Session 1 1 — E-mail Links, Comment s, and Special Charact ers

      Code

      Characte r Entity

      À

      À

      À

      Á

      Á

      Á

      Â

      Â

      Â

      Ã

      Ã

      Ã

      Ä

      Ä

      Ä

      Å

      Å

      Å

      Æ

      Æ

      Æ

      Ç

      Ç

      Ç

      È

      È

      È

      É

      É

      É

      Ê

      Ê

      Ê

      Ë

      Ë

      Ë

      Ì

      Ì

      Ì

      Í

      Í

      Í

      Î

      Î

      Î

      Ï

      Ï

      Ï

      F

      Ð

      Ð

      Ñ

      Ñ

      Ñ

      Ò

      Ò

      Ò

      Ó

      Ó

      Ó

      Ô

      Ô

      Ô

      Õ

      Õ

      Õ

      Ö

      Ö

      Ö

      ×

      ×

      Ø

      Ø

      Part I I I — Sat urday Af t ernoon Session 1 1

      Characte r

      147

      Ø Co ntinue d

      148

      Sat urday Aft ernoon

      Table 1 1 -1

      Co ntinue d

      Characte r

      Code

      Characte r Entity

      Ù

      Ù

      Ù

      Ú

      Ú

      Ú

      Û

      Û

      Û

      Ü

      Ü

      Ü



      Ý

      Ý

      T

      Þ

      Þ

      ß

      ß

      ß

      à

      à

      à

      á

      á

      á

      â

      â

      â

      ã

      ã

      ã

      ä

      ä

      &aauml;

      å

      å

      å

      æ

      æ

      æ

      ç

      ç

      ç

      è

      è

      è

      é

      é

      í

      ê

      ê

      î

      ë

      ë

      &emul;

      ì

      ì

      ì

      í

      í

      í

      î

      î

      î

      ï

      ï

      ï

      D

      ð

      ð

      Session 1 1 — E-mail Links, Comment s, and Special Charact ers

      Code

      Characte r Entity

      ñ

      ñ

      ñ

      ò

      ò

      ò

      ó

      ó

      ó

      ô

      ô

      ô

      õ

      õ

      õ

      ö

      ö

      ö

      ÷

      ÷

      ø

      ø

      ø

      ù

      ù

      ù

      ú

      ú

      ú

      û

      û

      û

      ü

      ü

      ü



      ý

      ý

      p

      þ

      þ

      ÿ

      ÿ

      ÿ

      One code not included in the table is   that creates a nonbreaking space. If you embed   between two words, for example, the browser will not break a line between them but will keep the two words together. Most browsers provide support for most of the characters in Table 11-1. If you use the special characters, test your page in several of the more popular browsers to make sure that the codes work as you expect. (Such advice is true of all pages; always view your Web pages in as many browsers and in as many different resolution levels as possible to ensure that your Web page retains the look you prefer.)

      Tip

      When you use one of t he special charact ers, a comment is necessary t o inform ot her HTML coders, as well as yourself , exact ly what t he charact er code represent s. Also, some, but not all, of t he special charact ers follow t he same charact er- code pat t ern as t he ASCI I t able.

      Part I I I — Sat urday Af t ernoon Session 1 1

      Characte r

      149

      150

      Sat urday Aft ernoon

      REVI EW 쐌 When clicked, e-mail links open up a mail window in your Web site that enables users to write to you easily. 쐌 An e-mail hyperlink includes the standard underlining and hyperlink colors. 쐌 Comments in your HTML code, such as a note to remind yourself to add a feature later on, make Web site maintenance much simpler. 쐌 Use character codes when you cannot produce special characters from your keyboard or when a special character, such as the less-than sign, might be interpreted as a command tag.

      QUI Z YOURSELF 1.

      Name three reasons to provide an e-mail hyperlink on your site. (See “Uses for E-mail Links.”)

      2.

      What is the protocol value that opens the user’s default e-mail’s new message window? (See “Creating E-mail Links.”)

      3.

      Why does the browser ignore comments? (See “Adding Comments to HTML Code.”)

      4.

      Why should you put contact information in your HTML code comments? (See “Adding Comments to HTML Code.”)

      5.

      Why must you use special character codes to display special characters on your Web page? (See “Inserting Special Characters on Web Pages.”)

      SESSI ON

      12 Tables Organize Dat a

      Session Checklist ✔ Learn the ways that tables can help yo u o rganize data o n yo ur Web site ✔ Learn how to prepare a spreadsheet- like table that yo u can use as a basis fo r co mplex tables ✔ Improve the lo o k of yo ur tables by adding bo rders, aligning data, and spanning cells acro ss co lumns and rows ✔ Use so me advanced page layo ut tricks to make mo re powerful tables

      o me of the mo st interesting Web sites wo rk well because they are built o n

      S

      tables. Mo st HTML tuto rials begin teaching HTML tables by making spreadsheet analo gies. The spreadsheet makeup of cells and rows is so familiar

      that such an analo gy makes a go o d place to start. Nevertheless, tables do n’t sto p with tabular data. Tables can ho ld any kind of data, no t just text. Unfo rtunately, a weekend crash co urse do es no t provide eno ugh time to make yo u an official Table Guru, but yo u will, befo re this sessio n ends, ho ld many table tips in yo ur bag of tricks that yo u will ho ne as yo ur use of tables grows.

      152

      Sat urday Aft ernoon

      How Tables Help You Organize Dat a Tables help yo u o rganize data o n yo ur Web site. So me of the ways yo u can use tables are to :

      쐌 Present newsletter info rmatio n in co lumns, as shown in Figure 12- 1. 쐌 Display tabular info rmatio n, in a spreadsheet- like manner, such as price lists and invento ries.

      쐌 Add bo rders aro und text and graphic images in a unifo rm manner. 쐌 Fo rmat yo ur entire Web page layo ut, including the placement of graphics, text, banners, sidebars, headers, and fo o ters.

      Figure 12-1 Table s he lp o rganize the data in ne wsle tte r We b site s.

      As yo u can see, tables are no t limited to simple spreadsheet- like fo rmatting, even tho ugh the best place to begin learning abo ut tables is to see them in use with such data. The rest of this sessio n develo ps such a spreadsheet- like table so yo u can learn the fundamentals. Yo u then can apply tho se fundamentals to o ther kinds of tables.

      Session 1 2 — Tables Organize Dat a

      153

      Preparing Columnar Dat a Tables Tables co nsist of rows and co lumns. A useful table might co ntain o nly o ne row and three co lumns. The purpo se of the table determines how elabo rate the table must beco me. Tables can be nested, which means that they can reside inside o ther tables. Therefo re, a single cell might co ntain an entire table, and o ne of the inside table cells might ho ld yet ano ther table.

      Never

      Tables require several different kinds of table- related co mmand tags. Yo u canno t type table text directly into HTML as rows and co lumns of info rmatio n because browsers igno re all extra spaces and tabs in yo ur HTML so urce.

      Creat ing t ables All tables begin with the

  • MIS Press
    M&T Books
    co mmand tag and terminate with a subsequent

    co mmand tag. Within the table, yo u’ll specify rows with the
    ( fo r table de tail) tag. In additio n to cells that ho ld data, yo u may also create header cells that ho ld titles fo r the data in the co lumns.

    Tip

    When you design and creat e t ables, keep t he following order in mind at all t imes: t op- t o- bot t om and lef t - t o- right . You’ll creat e all t ables one row at a t ime f rom t he t op t o t he bot t om of t he t able, and you’ll add individual cells, or columns, one at a t ime in t hose rows f rom t he lef t t o t he right .

    One of the best ways to begin a table that co ntains simple co lumnar data is to type the data directly into yo ur HTML co de. Remembering that HTML co mpletely igno res extra spaces and tabs that yo u use, yo u can mo re easily plan yo ur table by using yo ur text edito r to create the initial layo ut.

    Part I I I — Sat urday Af t ernoon Session 1 2

    Never embed more t han t wo levels of t ables if your Web page loads slowly. A single t able, even one wit h many rows and columns, loads much fast er t han a t able t hat cont ains ot her t ables. The power of t hese nest ed t ables, however, makes t hem so usef ul t hat your applicat ion should det ermine whet her or not you nest t ables inst ead of simply considering load t ime. I n addit ion, some browsers, most not ably Net scape 4 , do not display nest ed t ables properly unless t he user has upgraded t o a more recent version.

    154

    Sat urday Aft ernoon

    Do n’t just type the data in rows and co lumns, however, because yo u must remember the to p-to -bo tto m, left-to -right nature of HTML tables. Fo r example, type data in each row ( to p to bo tto m) , beginning with the first row. Befo re yo u type data in the next row, enter the co lumnar data ( left to right) fo r each row, o ne cell at a time. Co nsider the fo llowing co de that presents a bo o kseller’s invento ry:

    Title Quantity Price Laughing Kids 24 $19.95 I Stood Still 13 $7.95 Make Money Now 52 $22.95
    The first three items ( Title, Quantity, and Price) are the table’s co lumn titles, called he ade r ce lls in HTML termino lo gy. ( How to set up the co lumn heads is covered in the sectio n that immediately fo llows this o ne.) The remaining rows fall below the header cells. The co de, as it now stands, do es no t make much of a table. The tag do es no fo rmatting but serves o nly to tell the browser where the table might begin and end. Therefo re, all the text in this co de will appear in o ne line acro ss the browser screen. The text do es co mprise a table given the
    tag, however. Yo u must divide the text into rows and co lumns to make the table lo o k like a table.

    Specifying t he header cells The end tag. The co de fro m the previo us sectio n now lo o ks like this:
    tags specify which cells are header cells. Once yo u’ve typed the data, put

    tags befo re each header cell value. At the end of each header cell, include a


    Session 1 2 — Tables Organize Dat a

    155

    Laughing Kids 24 $19.95 I Stood Still 13 $7.95

    Title will appear at the to p of the table’s first co lumn; Quantity will appear at the to p of the table’s seco nd co lumn; Price will appear at the to p of the third co lumn.

    Specifying t he rows When yo u use the tags, yo ur table begins to lo o k like a real table. Insert

    befo re the data value that begins each row and at the end of each row. The co de lo o ks like the fo llowing:

    Title Quantity Price
    Laughing Kids 24 $19.95 I Stood Still 13 $7.95

    Part I I I — Sat urday Af t ernoon Session 1 2

    Make Money Now 52 $22.95
    Title Quantity Price


    156

    Sat urday Aft ernoon

    At this time, the table is shaping up in rows, as shown here:

    Title Quantity Laughing Kids 24 $19.95 I Stood Still 13 $7.95 Make Money Now 52 $22.95

    Price

    The t ag aut omat ically boldfaces t he header cells t o help separat e t hem f rom t he dat a cells. You can always format t he header and dat a f urt her wit h t he available format t ing t ags. Not e

    Obvio usly, the table needs wo rk. The data do es no t pro perly align in co lumns, but that sho uld no t be a surprise co nsidering no tags appear yet to separate the data into co lumns.

    Specifying t he columns Use the tag befo re each cell value, fo llowed by the end tag to specify co lumns. This will co mplete the standard table. Here is the co de to do just that:

    Title Quantity Price Laughing Kids 24 $19.95

    157

    Session 1 2 — Tables Organize Dat a

    I Stood Still 13 $7.95 Make Money Now 52 $22.95 The table now appears in nice rows and co lumns, with each co lumn wide eno ugh to ho ld either the lo ngest cell data o r the lo ngest header. Here is the table as it

    Title Laughing Kids I Stood Still Make Money Now

    Quantity 24 13 52

    Price $19.95 $7.95 $22.95

    Much wo rk is left, but the basic structure is now in place. It may seem as tho ugh HTML tables are time-co nsuming to create. However, yo u’ll co mbine many of the steps that this sessio n has bro ken down individually when yo u create yo ur tables. In additio n, yo u’ll begin fo rmatting the tables mo re appro priately earlier in the pro cess. The next few minutes co ncentrate o n table fo rmatting.

    I mproving t he Look of Your Table Think of all the improvements needed to make the bo o k invento ry a mo re useful table. The table’s lo o k wo uld benefit fro m lines aro und and in between the table cells. Headers sho uld co nsistently center o r left- justify over the co lumns, and the cell widths need to change so mewhat.

    Adding borders The tag suppo rts a border= attribute that draws bo rders ( o r lines) aro und and between yo ur table’s cells. The fo rmat of the tag and attribute are as fo llows:



    Part I I I — Sat urday Af t ernoon Session 1 2

    now stands:

    158

    Sat urday Aft ernoon

    The width value is the number of pixels wide the bo rder sho uld co nsume. To create a bo rder, therefo re, yo u might replace the o pening
    tag with this:

    Figure 12- 2 shows how a bo o kseller’s table with a bo rder appears in the browser window. The table lo o ks go o d, actually, co nsidering how little effo rt went into it.

    Figure 12-2 The table ’s shade d bo rde rs cre ate a profe ssio nal lo o k.

    Aligning dat a The table tags give yo u co mplete co ntro l over yo ur table’s fo rmat, including the alignment of the header and data cells against the left o r right edge of the bo rders as well as to o ther cells. Yo u can align entire rows and co lumns o r individual cells. The fo llowing HTML statement aligns a table header’s text so it left- justifies within the cell:

    The align= attribute wo rks in bo th header cells and data cells to align the data inside tho se cells to the left, center, o r right side of the cells in relatio n to the bo rder. Even within the same row of header cells, yo u may want to center so me headers and left- align o thers. In additio n to aligning data ho rizo ntally, yo u can align text vertically within a row with the valign= attribute. The valign= attribute takes these three values:

    valign=top, valign=middle, and valign=bottom.

    Session 1 2 — Tables Organize Dat a

    159

    Spanning individual cells and co lumns acro ss multiple rows in the table ( discussed next) is when yo u need to vertically align data.

    Spanning cells One of the mo st useful aspects of HTML tables is that each cell in each row do es no t have to co nfo rm to the width o r height of each cell in o ther rows. The uniqueness of the cells lends HTML tables to entire and co mplex Web page design. When the cells in each row are no t the same height and width, yo u can span individual cells and co lumns acro ss multiple rows. Fo r example, yo u can put the table’s title in yo ur first row and span the title acro ss the entire table. When using the tag to add a table title, in many ways, the the captio n stays with the table when yo u move the table and is actually part of the table. The tag falls directly below the
    Title
    tag, as fo llows:

    Our In-Stock Books Again, the captio n appears above the table. The browser do es no t even bo ldface the text as it do es fo r co lumn header cells. Yo u are welco me to apply any fo rmatting tags to the captio n as lo ng as yo u place tho se tags after the start tag, . Yo ur o ther o ptio n fo r fo lding a table title into the table itself is to place the title directly into the first cell of the first row and then span, o r lengthen, that cell to co nsume the entire width of the table. To span acro ss co lumns, yo u use the tag, and to span acro ss rows, yo u use the tag. The width value is the number of co lumns o r rows that yo u want the cell to span. The co de in Listing 12- 1 generates the table shown in Figure 12- 3, with the table title appearing directly inside the table. Because of the colspan=3 attribute, the first row spans all three co lumns. Witho ut the colspan=3 attribute, the row wo uld co nsume o nly the first co lumn of the table, and the rest of the table wo uld fall beneath that.

    Part I I I — Sat urday Af t ernoon Session 1 2

    tag offers little mo re than regular HTML text offers. The o nly exceptio n is that

    160

    Sat urday Aft ernoon

    Figure 12-3 Be cause of the co lspan= attribute, the table title now spans acro ss the thre e co lumns.

    Listing 1 2 -1 Using the co lspan= attribute to distribute a ce ll acro ss se ve ral co lumns



    Session 1 2 — Tables Organize Dat a

    161

    Our In-Stock Books
    Title Quantity Price
    Laughing Kids 24 $19.95
    I Stood Still 13 $7.95
    Make Money Now 52 $22.95


    More Powerful Tables So me of the fo rmatting tricks discussed in this sectio n can enhance the appearance of yo ur tables. Altho ugh tables ho ld data effo rtlessly, the page layo ut tricks and tips sequential, flat Web site. They lend themselves to mo re powerful Web page design.

    Adding a background color t o a t able Adding a backgro und co lo r to yo ur table makes the table stand o ut. Yo u can do this by adding the bgcolor= attribute inside the tag to co lo rize all the cells in the table. As with all HTML co lo r- related attributes, yo u can specify either a hexadecimal co lo r co de such as #20CCFF o r o ne of the 16 named co lo rs such as red ( as discussed in Sessio n 8) . The fo llowing statement co lo rs the cell’s backgro und blue:





    As is virtually always true fo r graphics o n yo ur site, yo u sho uld include the image’s width ( width=) and height ( height=) attributes so that the browser do es no t have to slow down to co mpute the dimensio ns. In additio n, the alt= attribute ensures that so mething appears even when the user has turned off graphics in the browser. The alt= attribute also yields a po p- up To o lTip that reads Family Logo if the user rests the mo use po inter over the lo go . The next cell ho lds bo th a graphic image of the mailbox and a hyperlink to the family’s e- mail address. Altho ugh the Barkleys plan to add an e- mail link elsewhere, o ne here is nice and the GIF image perfo rms a dual ro le: It acts as the hyperlink image and also co nveys the idea “ Here’s a Web page with Barkley news delivered to yo u.” The fo llowing co de defines the cell:



    317

    Session 2 3 — The Web Sit e Home Page’s HTML

    The fo ur no nbreaking spaces add so me ro o m to the left of the mailbox. Altho ugh the mailbox co uld be fit there thro ugh o ther metho ds, such as justifying the mailbox to the right edge of the cells, the no nbreaking spaces enable yo u to place the picture mo re accurately. Altho ugh yo u wo n’t add hyperlinks to this page until Sessio n 25, the Barkleys’ e- mail hyperlink ( mailto:[email protected]) is simple to add here befo re the mailbox graphic ( src=”mailbox.jif”) . Finally, the remaining cell that ho lds the text, All the news that’s news for you, very simply clo ses o ut the row by placing the go ld text o n the green backgro und. The no nbreaking spaces enable the Barkleys to adjust the spacing aro und the text to lo o k so mewhat centered. Listing 23- 4 shows the co mplete HTML co de fo r the Web page as it now stands. The header is co mplete.

    Listing 2 3 -4 The co mple te d he ade r table co de

    Part V— Sunday Morning Session 2 3





    The Barkley Family Web Page


    Adjust ing t able spacing Two attributes, cellpadding= and cellspacing=, enable yo u to place cells mo re precisely in relatio n to each o ther. Yo u must specify the attributes in pixels with the width value as fo llows:

    cellpadding=width cellspacing=width By adjusting the cellpadding= attribute, yo u add so me ro o m aro und yo ur cell’s text that is greater than the default pixel value of 1. The cellspacing= attribute increases the size of the space between the cells. The inner lines that divide the cells increase in width as yo u increase the cellspacing= attribute value.

    Part I I I — Sat urday Af t ernoon Session 1 2

    yo u learn here make tables almo st a requirement fo r anything mo re than a simple

    162

    Sat urday Aft ernoon

    The width= attribute enables yo u to determine exactly how much of the Web page yo ur table will span no matte r how wide the use r’s browse r window is. The default width of a table is the amo unt of space necessary to display that table. If, however, yo u specify a fixed width value, the table enlarges o r co ntracts to respect that width. If yo u do no t specify a width that is wide eno ugh to display the cell co ntents, the browser squeezes the table and wraps the co ntents of the cells to respect the width that yo u specify.

    Never specif y a t able widt h great er t han 5 5 0 pixels. Users wit h small displays will not be able t o see a wider t able reliably. Never

    Adjust ing t able space wit h percent ages and mult iple t ables Instead of specifying the width in pixels, yo u can specify the width= attribute in percentage terms. Therefo re, yo u can request that a table co nsume 85 percent of the browser’s remaining window size. Whatever the browser’s window size is, the browser will adjust to 85 percent of that size. By centering the table, yo u can ensure that the table maintains a unifo rm lo o k, in mo st cases, even tho ugh yo u canno t predict the size of the browser window that will display the table. Yo u can also use mo re than o ne table to help acco mplish appro priate spacing, amo ng o ther tasks. The example in this sessio n will go a lo ng way towards showing yo u what yo u can do with the knowledge of tables yo u now po ssess. Co nsider the partial Web page shown in Figure 12- 4. The autho r of this page wants this info rmatio n to span the user’s Web page no matter how wide o r how narrow the user sets the browser’s window. Altho ugh tables are simple to create and maintain, such a Web page element is no t simple witho ut the use of tables. The po rtio n of the Web page yo u see in Figure 12- 4 co ntains two table s, no t just o ne. The tables are o n to p of each o ther, and bo th tables co ntain o ne row each. The to p table, which fo rms the black band, co ntains o ne row and two co lumns, and the bo tto m table, which fo rms the text and the graphics, co ntains o ne row and three co lumns. The reaso n fo r the two tables is so the black band acro ss the to p of the three cells can expand o r co ntract as needed witho ut messing up the width of the text o n that band. In o ther wo rds, To day’s Eve nts resides in the first cell to maintain its spacing, size, and height no matter how wide o r narrow the Web page beco mes. Yet, the rest of the cell is black and expands to fill the window no matter how wide the Web page is.

    Session 1 2 — Tables Organize Dat a

    163

    Table s make profe ssio nal We b site e le me nts po ssible.

    Actually, the bo tto m table is larger but mo re straightfo rward. The Web page autho r created the o ne-row, three-co lumn table, centered the text and graphic images inside each of the three cells, set the bo rder size to 2 pixels, set the cellpadding to 10 pixels, and set the cellspacing to 5 pixels. ( The bo rder determines the thickness of the bo rder lines, and the cellspacing attribute determines how wide apart the lines are that co mprise the bo rder.) In additio n, the Web page autho r set the width= attribute in the bo tto m of the table to 100 percent. The table spans the user’s Web browser screen no matter how wide the screen beco mes. The fo llowing co de defines the bo tto m table:



      Please type your address:



    Figure 13-4 By using a mo no space d type face, yo u can align fo rm fie lds.

    Managing form fields Use these two attributes, size= and maxlength=, to co ntro l how the user enters info rmatio n into text boxes. The size= attribute determines how wide the text box, in characters, will be. Yo u can further limit the user’s input ( by characters) by specifying a maxlength= attribute. Therefo re, the fo llowing co de displays a ten- character field box, but the user can o nly enter eight characters in the field:



    Please type the product code:

    In additio n, yo u can specify a tabindex= attribute to co ntro l the tab o rder of input boxes that the user’s curso r jumps to as the user presses Tab. Assign a unique and sequential number, beginning with zero , to each field to co ntro l the tab o rder between the fields. Witho ut the tabindex= attribute, the tab o rder sho uld be the same as the o rder of fields o n the screen.

    Session 1 3 — Forms Add Funct ion

    175

    Keep in mind t hat t he tabindex= is a relat ively new HTML at t ribut e and not all recent browsers support it . However, it doesn’t hurt t o specif y a t ab order. Not e

    So metimes, yo u’ll want yo ur users to enter a secret co de in a field. Perhaps yo u want a passwo rd, credit card, o r o ther data that the user may no t want to appear o n the screen. So meo ne might be lo o king over the user’s sho ulder, so yo u sho uld hide the data as yo ur user enters that data. The type=password attribute, as o ppo sed to type=text, inside the tag handles passwo rds and o ther secret data fo r yo u. When yo u use a fo rm with a passwo rd field, asterisks ( *) appear o n the user’s screen as the user types the characters in the passwo rd.



    Please type your full name:



       Please enter a password:



    The passwo rd field is no t o nly set so that asterisks appear as the user types, but the field is also limited to ten characters wide, and the user can enter o nly eight characters maximum. The extra spacing adds so me padding that lo o ks better o n the screen than if yo u allowed a width that was the same limit as the passwo rd’s maximum length. Figure 13- 5 shows the resulting fo rm.

    Part I I I — Sat urday Af t ernoon Session 1 3

    The fo llowing co de co ntains a passwo rd field:

    176

    Sat urday Aft ernoon

    Figure 13-5 Hide passwo rds in We b page fo rm fie lds to pro te ct yo ur use rs.

    Furt her Field Refinement Yo u canno t co ntro l exactly how yo ur users enter data. In o ther wo rds, no fo rm can be perfect because no user is perfect. Yo u might want an address, but the user enters a pho ne number. Therefo re, yo u’ll have so me data validatio n to perfo rm o nce yo u receive yo ur data. Check to make sure, fo r example, that yo ur user didn’t enter a negative age o r a state abbreviatio n that’s no t o ne of the 50 states. The pro blem is that yo u canno t validate data inside HTML.

    Tip

    The CGI script t hat you or someone else writ es for your Web server can perform some dat a validat ion. For example, if t he user ent ers t oo f ew digit s for a social securit y number, t he CGI script can inform t he user of t he bad value and display t he form again wit h t he social securit y f ield blank.

    Altho ugh yo u canno t perfo rm true validatio n, yo u can help guide users by prefilling so me fields fo r them. Fo r so me fields, yo u know the user’s value in advance. Fo r example, the city and state might almo st always be yo ur own city and state if yo ur pro gram co llects data fro m lo cal residents o nly, o r if yo u are writing HTML Web pages fo r a co mpany’s intranet where all users reside at the same site. Fo r such fields, yo u may want to supply de fault value s — values that appear in the fields that yo ur users can keep, o r change if the data happens to be inco rrect.

    Session 1 3 — Forms Add Funct ion

    177

    Use the value= attribute to specify a default value. The fo llowing co de do es that:

    Please type your state:

    Default values require t he quot es around t he default value t hat you specif y in t he HTML code. Not e

    As Figure 13- 6 shows, the state abbreviatio n CA auto matically appears as the default value, but the user can change the state if ano ther happens to be co rrect. entry and accuracy.

    Figure 13-6 Supply co mmo n data value s fo r yo ur use rs.

    Large Text Areas Yo u do no t have to limit input fields to a single line. Yo ur input fields can span several rows and co lumns. These te xt are as enable users to enter freefo rm text. Such text may be beneficial fo r getting a user’s input in sites such as:

    쐌 Sites that ask fo r user feedback o n the site’s design 쐌 Custo mer service sites that require an explanatio n when the user requests a return autho rizatio n

    Part I I I — Sat urday Af t ernoon Session 1 3

    By supplying a default with the mo st likely value, yo u speed up yo ur users’ data

    178

    Sat urday Aft ernoon

    쐌 Message bo ard sites that ask the users fo r their o pinio ns A large text area might also be needed o n sites that request specific co ntact info rmatio n, such as name and address requests, to give the user an area fo r special instructio ns, such as the name and address fo rm shown in Figure 13- 7.

    Text area

    Figure 13-7 A large te xt are a fo r spe cial instructio ns is provide d o n this fo rm.

    The t ext area’s scroll bar becomes act ive when t he user t ypes more lines of t ext t han will f it inside t he t ext areas t hat you set up. The t ext will f it once t he scroll bar becomes act ive. Not e

    The and tags enclo se the field yo u want to specify as a text area. The tag suppo rts the fo llowing attributes:

    name=

    Names the text area field so that the CGI script o r e- mail that co mes back to yo u can identify the text area value.

    rows=

    Specifies the number of screen rows that yo u want to provide fo r the text area.

    cols=

    Specifies the number of screen co lumns ( characters) that yo u want to provide fo r the text area.

    179

    Session 1 3 — Forms Add Funct ion

    wrap=

    Determines whether o r no t the text auto matically wraps within the text area. Witho ut the wrap attribute, the browser may o r may no t wrap co mplete wo rds within the text area.

    Yo u can also specify default text within a large text area by putting text between the and tags. Fo r example, the fo llowing tags create a text area that spans 3 rows and 25 co lumns and displays Mailing information as default text in the text area:

    Mailing information

    REVI EW 쐌 Fo rms allow yo u to o btain structured and o rdered answers fro m yo ur Web page users.

    쐌 The and tags create the fo rm. 쐌 The user enters data in the fo rm’s fields. 쐌 Yo u co ntro l the name of the fields and their descriptio ns so yo u can distinguish the fields fro m o ne ano ther when the data returns to yo u via e- mail o r CGI script.

    쐌 Altho ugh yo u can’t perfo rm true validatio n o n fo rms, yo u can pre-fill o r add default values to so me fields to help prevent the inputting of invalid data.

    쐌 Text areas ho ld large amo unts of info rmatio n.

    Part I I I — Sat urday Af t ernoon Session 1 3

    Tip

    A read- only at t ribut e exist s ( specif ied as readonly=readonly) for t ext areas where you want t o display t ext but not allow t he user t o ent er new t ext . You, t hereby, show default t ext t hat t he user cannot change. Depending on t he user’s set t ings, you may want t o of f er t he t ext area as a read- only for some users or for some of your Web pages. The read- only t ext area maint ains t he form ’s appearance while displaying t he read- only t ext for your users. At a lat er t ime, or in anot her Web page, t he same form might appear wit hout t he read- only at t ribut e.

    180

    Sat urday Aft ernoon

    QUI Z YOURSELF 1.

    True o r False: The CGI script runs o n the Web server’s co mputer. ( See “ CGI Retrieves Yo ur Data.” )

    2.

    What appears o n the screen in a passwo rd field? ( See “ Managing Fo rm Fields.” )

    3.

    Where do yo u send yo ur fo rm fo r user accuracy validatio n? ( See “ Further Field Refinement.” )

    4.

    What is a default value? ( See “ Further Field Refinement.” )

    5.

    What is the difference between a text field and a text area? ( See “ Large Text Areas.” )

    SESSI ON

    14 Adding Form Element s

    Session Checklist ✔ Create check boxes fo r yo ur fo rms ✔ Place radio butto ns o n yo ur fo rms ✔ Display selectio n lists, including pick lists, o n yo ur fo rms ✔ Learn how to create the submit and reset butto ns to enable users to either submit the fo rm’s data o r redo the fo rm

    his sessio n expands o n the previo us sessio n’s lesso n abo ut fo rms. In this ses-

    T

    sio n, yo u will learn additio nal co ntro ls that yo u can place o nto fo rms that enable yo ur users to indicate cho ices and select o ptimum o ptio ns. Yo u’ll learn

    how to place co ntro ls such as check boxes, radio butto ns, selectio n lists, and reset and submit butto ns, all of which are co mmo n to mo st users of graphical user interfaces such as the Macinto sh- and Windows- based platfo rms.

    Creat ing Check Boxes Figure 14- 1 shows a fo rm with check boxes. When yo u set up check boxes, yo u can place o ne o r mo re check box items o n a fo rm. In additio n, yo u can check o ne o r

    182

    Sat urday Aft ernoon

    mo re of the items by default so the user do esn’t have to change anything if he o r she wants to accept the default values. By clicking a check box, the user either selects o r deselects the check box item. Generally, yo u’ll use check boxes when yo ur user must cho o se zero , o ne, o r mo re items fro m a list of several items.

    select ed check boxes

    Figure 14-1 The use r se le cts o ne o r mo re ne wsle tte rs to re ce ive by clicking o ne o r mo re che ck boxe s.

    No tice that a check box has a descriptio n and a box to the right of the descriptio n. When checked, the box displays a checkmark that indicates the user’s preference. To set up a check box, inside a tag pair, insert the fo llowing tag:

    In the preceding tag, nameOfCheckbox is a name yo u supply so that the subsequent CGI script can sto re the value in a unique lo catio n, o r so that the e- mail yo u receive fro m the fo rm will have a name to assign the user’s value to . The value=

    Session 1 4 — Adding Form Element s

    183

    attribute is the value assigned to that name in the CGI script o r the e- mail that co mes back to yo u fro m the fo rm. In additio n, the checked=checked attribute lets yo u set up default values in yo ur check boxes. Co nsider the fo llowing co de that sets up six check box o ptio ns:



    Figure 14-2 shows the fo rm with check boxes that results fro m this co de. Po tato es and co rn have default checks set up, as indicated by the checked=checked attributes. Altho ugh yo u do n’t have to assign a value to the checked attribute, do ing so ensures that yo ur Web site will be co mpatible with future browsers that might require the assignment fo r co nsistency. At first, it may seem strange that the name attribute values fo r each of the check boxes is the same and that the value= attributes are all different. Also , the

    value= attributes seem to match the text that appears o n the screen next to the check box. The name= attribute indicates the name that appears in the CGI script o r e-mail that co mes back to yo u, and the value assigned to that name is the value fo llowing

    value=, as mentio ned earlier. Therefo re, if the user selects all six of the vegetables, the values that the fo rm will pro duce are:

    veggies=Potatoes veggies=Cabbage veggies=Corn veggies=Carrots veggies=Legumes veggies=Peas

    Part I I I — Sat urday Af t ernoon Session 1 4



    Please select your favorite vegetables:

    Potatoes
    Cabbage
    Corn
    Carrots
    Beans
    Peas

    184

    Sat urday Aft ernoon

    Figure 14-2 Pro ducing the che ck boxe s is a simple task.

    No tice that the fifth value assigned is Legumes, the same value as the value= attribute fo r that item. The descriptio n that appears o n the screen, however, is

    Beans because Beans is the descriptio n that fo llows the tag and that’s the value that appears as text next to the check box.

    Creat ing Radio But t ons Once yo u master check boxes, radio butto ns are extremely easy. They are almo st exactly the same as check boxes except that radio butto ns allow o nly zero o r o ne cho ice fro m the entire gro up of radio butto ns.

    Not e

    I n older cars, radios had push but t ons t hat select ed one and only one radio st at ion at a t ime. When you pushed one but t on in, what ever but t on t hat was pushed in previously popped out . Radio but t ons act t he same way on forms.

    Session 1 4 — Adding Form Element s

    185

    Altho ugh the user can select o nly o ne radio butto n fro m a gro up of radio butto n selectio ns, yo u can display mo re than o ne gro up of radio butto ns o n a Web page at the same time. Therefo re, the user can select a maximum of o ne radio butto n fro m each gro up, but o n the who le Web page, multiple radio butto ns will be selected. To set up a radio button inside a tag pair, insert the following tag:

    The o ptio nal ( and seemingly redundant) checked=checked entry o n o ne of the radio butto ns makes it the default butto n in the list. Only o ne radio butto n can be the default. The fo llowing co de pro duces the survey shown in Figure 14- 3. The

    Computer Survey PC

    Mac

    Under 64 Meg 64 to 128 Meg Over 128 Meg



    Under 3 Gig

    3 Gig to 7 Gig Over 7 Gig

    Yo u’ll no tice that a do t appears next to a selected radio butto n, whereas a checkmark appears next to a check box. Also , if a butto n is selected and the user clicks ano ther radio butto n within the same gro up, the first selected radio butto n will beco me deselected. No tice that in Figure 14- 3 two of the radio butto ns are selected already by default because of the checked=checked attribute.

    Part I I I — Sat urday Af t ernoon Session 1 4

    fo rm co ntains three sets of radio butto ns.

    186

    Sat urday Aft ernoon

    Figure 14-3 One and o nly o ne radio butto n can be se le cte d fro m any gro up of radio butto ns.

    The name= at t ribut e det ermines which set of but t ons go t oget her in a group. Not e

    Creat ing Select ion List s Se le ctio n lists, also known as list boxe s, dro pdown lists, scro lling lists, pick lists, and pull-down lists depending o n their style, offer the user a list of cho ices fro m which

    to cho o se. Unlike check boxes o r radio butto ns, selectio n lists can co nsume very little screen space while still offering the user a large list of alternatives. Yo u’ve seen selectio n lists befo re. Figure 14- 4 shows o ne Web site with a series of selectio n lists. One of the lists is o pen because the user clicked that list’s down arrow to view the o ptio ns in the list. The remaining lists stay clo sed and save screen ro o m.

    187

    Session 1 4 — Adding Form Element s

    select ion list s click t o open list

    Part I I I — Sat urday Af t ernoon Session 1 4

    open select ion list

    Figure 14-4 Se le ctio n lists o pe n to display the list of available cho ice s.

    Not e

    Technically, a pick list is a select ion list where t he user can select one and only one it em. I n a way, a pick list is a replacement for a set of radio but t ons: You can display a pick list or a list of radio but t on opt ions when you want your user t o select a single it em f rom a list of it ems. A select ion list , like a list of check boxes, allows for t he select ion of mult iple it ems f rom t he list .

    Displaying a select ion list To set up a selectio n list o n yo ur fo rm, yo u must enclo se the list inside and tags. The tag info rms the browser that a selectio n list is

    188

    Sat urday Aft ernoon

    abo ut to appear. In additio n to the name= attribute, yo u sho uld specify a size= attribute that determines how many items appear in the list o n the screen at o ne time. A list may have 40 o ptio ns but may o nly show three o n the screen, inside the clo sed selectio n list, at any o ne time. Scro ll bars enable the user to scro ll thro ugh the cho ices three at a time. Yo u might cho o se to display o nly o ne item fro m the clo sed selectio n list. The clo sed selectio n lists in Figure 14- 4 display o nly o ne item. Each item in the selectio n list must appear between an and tag pair. The fo llowing co de pro duces two selectio n lists, o ne with fo ur o ptio ns always appearing o n the screen and the o ther with o nly o ne line appearing. The user can display all the values of the seco nd selectio n list by clicking the list’s down arrow and viewing the rest of the o ptio ns. The first item in each list is already selected because of the selected=selected attribute.

    Peripheral Order Printer Selection:

    PH LasetPrint 4EZ OKY DOKY InkJet 949 Panamount InkJet Series a3 Canyon BCJ 3 Pioneers LaserQuiet Sonny 54 DaisyWheel Blue Moon Ribbonless



    Storage Selection:

    Jazzy 2Gig removable Cheata 5 Gig MaxStorage 3.9 Gig MaxStorage 8.7 Gig

    Session 1 4 — Adding Form Element s

    189

    SlowMoving Tape System 4.1 Gig BroadStore 9 Gig removable One set of hole-punch cards

    Figure 14- 5 shows the two selectio n lists that appear fro m this co de.

    select ion list s click t o open

    Part I I I — Sat urday Af t ernoon Session 1 4

    Figure 14-5 Two se le ctio n lists, o ne with fo ur o ptio ns displaye d and ano the r with o nly o ne o ptio n displaye d

    The multiple=multiple attribute enables the user to select multiple items fro m the selectio n list, unlike a pick list that wo uld no t co ntain this attribute. Mo st browsers suppo rt just the multiple attribute witho ut the redundant

    =multiple assignment, but fo r future co mpatibility, yo u sho uld assign the attribute.

    190

    Sat urday Aft ernoon

    The user sho uld keep the fo llowing things in mind when selecting multiple list items:

    쐌 Ho ld the Ctrl key while clicking o n each item. 쐌 When selecting items that appear to gether, click the to p item, scro ll down to display the final item, ho ld Ctrl and Shift, and click the final item. The browser will select all items between the first and final items inclusively.

    쐌 Click o n a selected item again to deselect it. The values returned fro m the fo rm’s e- mail o r CGI script will be the selectio n list’s name assigned to each selected value’s text that appears between the

    tags. In o ther wo rds, o ne po ssible script fro m Figure 14- 5’s sessio n might co ntain the fo llowing data:

    printers=PH LaserJet 4EZ printers=Canyon BCJ 3 storage=Jazzy 2Gig removable storage=Cheata 5 gig storage=SlowMoving Tape System 4.1 Gig The o ne- line selectio n list shown in Figure 14- 5 is actually awkward because of the extremely small scro ll bar. By no t allowing fo r mo re than o ne line to show at o ne time, the size=1 attribute severely limits the usability of this co ntro l. Witho ut multiple lines, the user has a difficult time determining how many items are actually selected. Perhaps the co ntro l sho uld be expanded to display multiple lines at o ne time, o r perhaps the data better fits a pick list where o nly o ne item can be selected fro m the list at o ne time. The next sectio n explains how to set up a pick list.

    Displaying a pick list In the fo llowing situatio ns, yo u want to display a pick list:

    쐌 Yo u want to devo te o nly o ne line of the screen to the entire selectio n list, except when the user o pens the list by clicking the down arrow.

    쐌 The user can select o ne and o nly o ne item fro m the list.

    Not e

    You can display a pick list and st ill specif y a size at t ribut e great er t han 1 . A scroll bar appears, and t he pick list spans more t han a single row. The user, however, will not be able t o select more t han one value if you do not specif y t he multiple=multiple at t ribut e.

    Session 1 4 — Adding Form Element s

    191

    If yo u do no t initially set up the pick list with a selected=selected attribute specified, no o ptio n will be selected when the user first sees the list, but as so o n as the user clicks the down arrow to o pen the list, the browser will select the first item in the list by highlighting that item. The user then can select a different item. Once the user selects an item by clicking o n that item, the pick list clo ses back to a o ne- line selectio n list, and the clicked item beco mes the item that appears in the o ne- row selectio n list box. The fo llowing co de displays the sto rage items as a pick list, and Figure 14- 6 shows the resulting pick list o pen with o ne of the items selected by the user.

    Storage Selection:

    You must do this: 1. Buy a plane ticket (expensive)
    2. Buy a car
    3. Buy a ticket (cheap)
    4. Get exercise

    206

    Sat urday Aft ernoon

    Your low- resolut ion image must mat ch t he high- resolut ion image in pixel size or t he second image will not replace t he f irst one properly. Not e

    Once yo u create a scaled- down versio n of a high- reso lutio n, slow- lo ading image, yo u can specify the low- reso lutio n image with the use of the tag, as fo llows:

    The lowsrc= attribute displays the low-reso lutio n versio n of the image. That lowreso lutio n image displays while the higher-reso lutio n image, specified by the src= attribute, lo ads in the backgro und. When the browser finishes lo ading the highreso lutio n image, the browser replaces the low-reso lutio n image with the better graphic.

    Session 1 0 explains how t humbnail images are used.

    Cross-Ref

    A low- reso lutio n image, specified with the lowsrc= attribute, is no t the same thing as a thumbnail image. With a thumbnail image, yo u have to take actio n to see the larger and higher- reso lutio n image. With the low- reso lutio n image specified with the lowsrc= attribute, the Web browser auto matically lo ads the lowerreso lutio n image first and then replaces that low- reso lutio n image with the high- reso lutio n image as so o n as the larger image finishes arriving fro m the Web server.

    REVI EW 쐌 Transparency creates a see- thro ugh effect fo r GIF image backgro unds. 쐌 Yo u need to use a graphics pro gram to co nvert a GIF image to a transparent GIF image.

    쐌 Anti- aliasing can cause extra co lo rs to interfere with transparency. 쐌 Keep a transparent o ne- pixel image handy to act as a filler when yo u need exact spacing between text and graphics o n yo ur Web page. The image gives yo u mo re precise co ntro l than tables do .

    쐌 A low- reso lutio n image can lo ad much faster so that yo ur users can view so mething until the higher- reso lutio n equivalent image lo ads and appears.

    Session 1 5 — Transparent I maging

    207

    QUI Z YOURSELF 1.

    How many co lo rs can be transparent at o ne time in a typical transparent GIF image? ( See “Abo ut Transparent Images.” )

    2.

    True o r False: Yo u can make an image transparent with HTML. ( See “ Making Images Transparent.” )

    3.

    What do es an alpha channel do ? ( See “ Transparency Pro blems Caused by Anti- Aliasing.” )

    4.

    When might a halo effect appear? ( See “ Transparency Pro blems Caused by Anti- Aliasing.” ) Why are images that are specified with the lowres= attribute no t co nsidered thumbnails? ( See “ Specifying a Low- Reso lutio n Pro to type.” )

    Part I I I — Sat urday Af t ernoon Session 1 5

    5.

    SESSI ON

    16 Advanced Color and I maging Techniques

    Session Checklist ✔ Understand that Web- safe black- and white- co lo rs may be safe but do no t always pro duce great results ✔ Keep yo ur site less crowded by utilizing whitespace ✔ Create navigatio n bars to give yo ur users a familiar way to traverse yo ur site ✔ Create banners to divide yo ur site so that users can easily distinguish between co mmo n areas ✔ Master graphics tips and sho rtcuts to make eye- catching Web pages

    A

    s Sessio n 8 explained, yo u sho uld use o nly the 216 Web- safe co lo rs if yo u want to maintain co nsistency acro ss the range of browsers used to day, and yo u sho uld use co lo rs that wo rk well to gether, which is no t always easy

    given the 216 Web- safe co lo r limits. In this sessio n, yo u learn so me additio nal co lo r issues and tips to co nsider when designing Web sites. Yo u also learn so me additio nal graphics techniques, namely creating navigatio n bars and banners.

    210

    Sat urday Aft ernoon

    A Problem wit h Displaying Black-and-Whit e Phot os The pro blem with using o nly Web- safe co lo rs is the low number of Web- safe co lo rs available: 216. If yo u do no t want a user’s browser to substitute ano ther co lo r fo r a co lo r yo u desired, stick with the Web- safe co lo rs. Altho ugh the user’s reso lutio n might make yo ur Web site lo o k different, at least the co lo rs are safe and will co me acro ss to the end browser pro perly. A pro blem o ccurs when yo u limit yo ur Web page design to 216 co lo rs but yo u attempt to display black- and- white pho to s o n yo ur page. As the artist Ansel Adams proved, black- and- white pho to graphy can be beautiful and can co nvey to nes and feelings that get lo st in co lo r pho to graphy. Perhaps yo u have black- andwhite pho to s of relatives fro m lo ng ago that yo u want to put o n yo ur site. Yo ur site may be a histo rical site that shows Old West pictures o r mo bster bo sses fro m the ro aring twenties. If yo u put the pictures o n yo ur Web page, yo u’ll so o n see that they have a co lo r pro blem. The black-and-white pictures can appear grainy. At first, this makes no sense because the co lo rs black and white are a part of the 216 Web-safe co lo rs. Black uses the hexadecimal co lo r #000000, and white uses #FFFFFF. Black and white are even amo ng the 16 named co lo rs that yo u can assign to backgro unds and text. The fo llowing co de, which changes the co lo r of specific text, is allowed and sho uld wo rk in all browsers yo ur users use:

    Nevertheless, a black- and- white pho to co ntains many mo re co lo rs than black and white. It may co ntain hundreds of shades of grays, wo rking as black- and- white transitio nal co lo rs. Table 16- 1 lists the o nly fo ur shades of gray that the 216 Websafe co lo rs include.

    Table 1 6 -1 Browse r-Safe Shade s of Gray

    De cimal

    Hexade cimal Equivale nts

    51- 51- 51

    #333333

    102- 102- 102

    #666666

    153- 153- 153

    #999999

    204- 204- 204

    #CCCCCC

    Session 1 6 — Advanced Color and I maging Techniques

    211

    The answer is, no go o d answer exists. If yo u must use black- and- white pho to graphy, yo u are stuck with lo usy pictures due to the limited co lo r renditio n, o r yo u must increase the number of co lo rs yo u use and ho pe fo r the best when the user browses yo ur page. Use JPEG images and no t GIFs, as JPEG grays render better than GIFs.

    Never

    Never make assumpt ions about color subst it ut ion. I f you of f er a pict ure wit h mult iple shades of gray on your sit e, browsers are f ree t o t urn your light grays int o pink if t he browser should deem it necessary.

    Yo ur Web page design co uld benefit fro m white space, also called ne gative space, which, basically, is blank space between elements. Ample whitespace in yo ur Web page is crucial so that yo ur pages do n’t take o n a to o - busy appearance. ( However, keeping yo ur Web page free of clutter isn’t always po ssible due to the lack of screen real estate fo r which yo u must design.) White is a tremendo us design to o l that is underutilized by many Web masters. But do n’t limit whitespace just to the co lo r white, because whitespace is mo re of a co ncept than a co lo r. Use whitespace to gro up items to gether o r to keep items spaced apart. Fo r example, instead of keeping bo rders aro und every cell of every table yo u create, and instead of overusing the ho rizo ntal rule, co nsider do ing no thing but separating yo ur Web page elements with blank space. Co nsider the simple Web page shown in Figure 16- 1. The message is simple, the page is simple, but the page co ntains to o much of so mething. What can it be? The answer is that the page co ntains to o much of e ve rything. To o much no nwhitespace exists. The page is overly busy. Even with the browser’s to o lbars and status bar turned off, the page do esn’t co mpletely fit the browser window in spite of the small amo unt of info rmatio n presented. Obvio usly, this is an extreme example, but co nsider what happens when o ne do es away with the fluff while still keeping the message. Figure 16- 2 shows a much simpler example, yet it wo rks very well. The graphics are spaced better, the backgro und do esn’t co nsume the message, the design and layo ut are slightly underdevelo ped but far less busy, and the page is hands- down a better Web page. Even with the status bar and to o lbar o n, the page fits well.

    Part I I I — Sat urday Af t ernoon Session 1 6

    Design Tip: Whit e Works Well

    212

    Sat urday Aft ernoon

    Figure 16-1 Do e s a de sign pro ble m e xist with this We b page ?

    Figure 16-2 Se parating e le me nts with no thing mo re than white space improve s this We b page.

    Session 1 6 — Advanced Color and I maging Techniques

    213

    Creat ing Navigat ion Bars One of the mo st useful places fo r GIF- based ico ns is in navigatio n bars. An ico n is a small image that represents so mething else, such as the images yo u see next to the Windows Start menu o ptio ns. A navigatio n bar wo rks like a menu fo r yo ur Web page, co ntaining a series of ico ns that appears acro ss the to p of the screen o r alo ng the edge of the screen. Figure 16- 3 shows a navigatio n bar that can appear at the to p of a Web page. The user clicks an ico n, and that ico n’s page, represented by a hyperlink, lo ads and displays o n the user’s screen. The nice thing abo ut navigatio n bars is that yo u will pro bably use the same navigatio n bar o r parts of the same navigatio n bar in sevpage o n the site so that the user can easily traverse the site with the familiar bar.

    Tip

    Navigat ion bars can help reduce your sit e’s page- loading t ime if you put t he navigat ion icons in your images folder. Don’t be af raid t o use t he same image t wice on your Web sit e. Many of your sit e’s pages, for example, may share t he same navigat ion bar or part s of t he navigat ion bar. By using t he same GI F image, and by put t ing all your images inside t he sit e’s images folder ( as discussed in Session 7 ) , you ensure t hat t he user’s browser only has t o download your graphic images once even if t he images appear mult iple t imes t hroughout your sit e.

    Here is the co de that pro duced the navigatio n bar in Figure 16- 3:





    Each of the frames described in Listing 18- 2 co ntains a target=main attribute. Actually, unless yo u put a hyperlink reference inside each of the frame windows, no t every frame needs the target=main attribute, but co ding the attribute means yo u will have less wo rries if later yo u do decide to add a link to o ne of the frames.

    Part I V— Sat urday Evening Session 1 8





    246

    Sat urday Evening

    By specifying target=contents, yo u tell the browser that any hyperlink reference fro m that particular frame sho uld no t change the current window but sho uld change the window named co nte nts, which is the detailed window in the large, central po rtio n of the Web page. The window named co nte nts do es no t require the

    target=contents attribute, because witho ut the attribute, it fo llows whatever hyperlink is clicked inside that window frame. Yo u must edit each of the Web pages in each of the frames to ensure that they update the pro per window frames — mo st usually, the frame ho lding the co ntent window. In o ther wo rds, yo u now must edit the navigatio n page’s HTML so that the hyperlinks all refer to the co ntents window. One po ssible cro ss- reference might appear as fo llows inside auctionnav.htm:



    Check out last week’s auctions

    Ot her frames can change In many instances, the co ntents frame is no t the o nly frame that sho uld change as the user navigates the site. Fo r example, links o r butto ns that perfo rm links in the banner area might pro duce a co mpletely different set of navigatio n links if yo u’ve placed a navigatio n bar in the left frame. Therefo re, yo u can set the

    target= attribute to the name of any window frame o n the Web page. When the user clicks a link in any frame, any o ther frame, referenced by name, can change. Yo ur Web page determines how yo ur site’s frame windows cro ss- reference each o ther.

    Tip

    Just because a Web sit e uses f rames does not mean t hat you are limit ed t o f rames for t he hyperlinks. Open links inside f rame windows or open a brand new window ( using t he target=”_blank” at t ribut e as you learned in Session 1 0 ) if t he informat ion resides bet t er in it s own f rameless window. The user can always close t he new window and ret urn t o t he f rame- based sit e.

    Help for non-frame browsers If yo u want yo ur users witho ut frame- aware browsers to understand why they do n’t see anything when they visit yo ur site, yo u can add so me co ntent to yo ur frameset HTML. Enclo se a message to the users inside the and

    Session 1 8 — Page Layout wit h Frames

    247

    tags. If the browser suppo rts frames, that browser igno res the tag co ntents, so yo u wo n’t mess up the users who se browsers are frame- aware. Listing 18- 3 shows simple co de yo u can add to all yo ur frame- based Web pages that info rm the frameless browser users why the site is o therwise vacant.

    Listing 1 8 -3 Using the tag in HTML fo r use rs who canno t display frame s

    www.Auctionner.com



    Sorry.

    Your browser does not support frames which this uses. An alternative frameless version of this Web page is now available for you to use.



    Part I V— Sat urday Evening Session 1 8







    248

    Sat urday Evening

    REVI EW 쐌 Frames, which offer a way fo r yo u to separate areas of a Web page, are used fo r displaying headers, navigatio n bars, fo o ters, and a large co ntent area.

    쐌 Frames differ fro m tables in that frames usually appear and o ne frame’s links can co ntro l the co ntents of ano ther frame window.

    쐌 Yo u can overuse frames to the po int that the frames begin to clutter the user’s screen.

    쐌 Befo re creating frame- based HTML, sketch yo ur Web site’s pages so that yo u know which frame will ho ld which co ntent.

    쐌 After sketching yo ur Web site’s pages, create all the frame window pages befo re wo rking o n the frameset itself.

    쐌 The and tags determine the rows and co lumns of a framed page.

    쐌 Altho ugh yo u do n’t want to put co ntent in the bo dy sectio n of yo ur frameset HTML, yo u can include co de fo r tho se users who canno t display frames.

    QUI Z YOURSELF 1.

    Name two ways that frames differ fro m tables. ( See “ Frames Separate Web Page Co ntent.” )

    2.

    When will scro ll bars appear inside a frame? ( See “ Frames Separate Web Page Co ntent.” )

    3.

    What is a frameset? ( See “ Frame- Based HTML.” )

    4.

    What attribute co ntro ls the appearance of scro ll bars? ( See “ Frame- Based HTML.” )

    5.

    What attribute o pens a new window inside o ne of the page’s frames? ( See “ Linking the Frames.” )

    SESSI ON

    19 Act ivat ing Pages wit h Mult imedia and Rollovers

    Session Checklist ✔ Speed up yo ur multimedia pro cesses with bandwidth ✔ Add so und to yo ur Web site ✔ Add video to yo ur Web site ✔ Learn how to co de the ro llover effect, thereby offering movement to Web pages

    W

    hy wo uld yo u want to add multimedia elements to yo ur Web pages? To make the pages mo re enjoyable, to make them stand apart fro m the crowd, to give them zing! Why wo uld yo u no t want to add multimedia

    elements to yo ur Web pages? After 18 sessio ns, yo u know the answer: Extras will slow yo ur page- lo ading time and lo se viewers. In this sessio n, yo u learn how to add multimedia and changing co ntent while still maintaining quick- lo ading pages.

    250

    Sat urday Evening

    Speeding Up t he Mult imedia Process wit h Bandwidt h Fo rtunately, yo u have time o n yo ur side. Bandwidth, the avenue of speed o n which Web pages travel, is o nly getting faster, no t slower. The faster the average user’s bandwidth beco mes, the mo re successfully yo u can add multimedia to yo ur site. Still, yo u need to be co nservative a while lo nger, because mo st users are still tied to mo dem techno lo gy and will be fo r a few mo re years. Some Web sites require more multimedia than others. For example, you may want to present audio information in a radio show format. You might create a Web page for a movie production company that wants to embed previews on the site. Such sites can be slower than normal for the slow-bandwidth users because these users know what to expect. This session describes the multimedia options you have for Web pages.

    Adding Sound t o Web Pages So und is perhaps the easiest fo rm of multimedia to add to a Web site. Yo u can play a Windows-like intro clip as so meo ne first views yo ur site. In additio n, yo u might want to put a list of reco rded co nferences fro m yo ur co mpany meetings o n the site. Table 19- 1 lists the mo st co mmo n audio fo rmats that yo u can sto re o n a Web page. By far, the mo st po pular fo rmats are MPEG fo r music files and RealAudio fo r radio and vo ice files.

    You can learn more about t hese t wo format s at http://www.mp3. com/ and http://www.real.com/. Bot h sit es of f er players you Cross-Ref

    can use t o preview audio clips, and bot h provide much cont ent for your enjoyment .

    Many sites use sho rt WAVE so und clips to welco me a user to the Web page. Sho rt clips do n’t co nsume much lo ad time, altho ugh they certainly impact the lo ad time. If yo u want to use a so und clip, yo u can find several by searching yo ur co mputer’s disk drive fo r tho se that yo ur o perating system utilizes fo r its messages. In additio n, http://www.wavecentral.com/ offers several WAVE files yo u can use, bo th royalty- based and royalty- free, fo r so und effects.

    251

    Session 1 9 — Act ivat ing Pages wit h Mult imedia and Rollovers

    Table 1 9 -1 Co mmo n Audio Fo rmats

    Name

    Exte nsion

    De scription

    MIDI

    .mid

    Individual instrumental so unds

    MPEG

    .mp3

    So ngs and o nline radio bro adcasts, often used fo r sto ring audio CD co ntent o n co mputers

    RealAudio

    .ra o r .rm

    So ngs, vo ice, and o nline radio bro adcasts

    WAVE

    .wav

    So unds such as tho se pro duced by Windows

    Sound wit h HTML A so und clip requires very little effo rt to include o n a Web page. Basically, yo u create a hyperlink to the so und file just as yo u might create a link to ano ther Web Windows 98 start- up so und o n a Web page. Figure 19- 1 shows the Web page that this sho rt HTML co de pro duces.

    Listing 1 9 -1 Providing the Windows 98 start-up so und o n a We b page

    Starting Windows 98

    Windows 98 Tutorial The Start-up Once you start a computer running Windows 98, the computer performs a self-test and then
    Windows 98 loads. Toward the end of the loading, you’ll hear the Windows 98 Co ntinue d

    Part I V— Sat urday Evening Session 1 9

    page. Co nsider the HTML co de in Listing 19- 1, which describes and provides the

    252

    Sat urday Evening

    Listing 1 9 -1

    Co ntinue d

    start-up sound.



    Figure 19-1 Whe n the use r clicks the hype rlink, the so und plays.

    Tip

    Just as you save your sit e’s graphics in a single images direct ory, save your sounds in t heir own folder as well, named “sounds.” I f a sound appears t wice t hroughout a sit e, t he user’s browser only has t o load t he sound once. I f t he same clip appears in mult iple direct ories, t he browser has t o load t he same sound t wice. Once you creat e video cont ent , as explained in t he sect ion named “Adding Video t o Web Pages,” you should st ore t he video in it s own folder called “videos” as well.

    Bet t er sound management When offering so und o r any o ther kind of multimedia event, be sure to provide the size of the clip, perhaps in a To o lTip message. Give the user so me idea of the length of the clip and the size of the file. Otherwise, the user may have to wait lo nger than expected fo r the clip to lo ad. By adding the fo llowing title to the hyperlink in Listing 19- 1, yo u enable the user to rest the mo use curso r over the link to preview the so und parameters befo re deciding to play the so und:

    Windows 98 start-up sound

    Session 1 9 — Act ivat ing Pages wit h Mult imedia and Rollovers

    253

    No t o nly do es such a title help warn the user that a lo ng delay may be waiting ahead, but also , users witho ut so und equipment and hearing- impaired users will know what the link pro duces fro m yo ur descriptio n. Depending o n the type of so und file, yo ur user may o r may no t be able to play the clip witho ut so me kind of accesso ry pro gram. Altho ugh mo st users can play WAVE files, no t all users have an MPEG o r a RealAudio player o n their system. If they do no t, and if ano ther so und player such as Windows Media Player o r the Mac’s QuickTime player do es no t suppo rt yo ur so und file’s fo rmat, the user will no t hear the audio . Yo u may want to provide a link to the fo rmat’s ho me site, such as the RealAudio Web site, so that the user can go there to downlo ad the pro per player befo re clicking o n yo ur so und’s link. The pro blem is that the users will often move o n to ano ther site rather than spend the time downlo ading the right player. Fo rtunately, MPEG and RealAudio fo rmats are so po pular to day that yo u can usually assume that users have the co rrect players needed fo r yo ur clips.

    Adding Video t o Web Pages sume massive amo unts of sto rage and bandwidth. Nevertheless, mo re and mo re sites are providing limited if no t full video capabilities fo r their users. Movie sites provide film previews, training co mpanies provide o nline walk- thro ughs, and news services frequently provide news clips of the to p sto ries o n their ho me pages. The advent of the video co nnectio n po rt fo r many of to day’s new co mputers also means that mo re perso nal ho me pages will be putting up mo re and mo re video s of the family and pets. Obvio usly, preparing the user fo r a po ssibly lo ng wait is extremely impo rtant if yo u provide video clips. Tell the user exactly how large the file will be and how many seco nds o r minutes of playtime the file co nsumes.

    Not e

    You can provide some video, as well as audio such as RealAudio f iles, in a st reaming format . I nst ead of t he user having t o wait for t he ent ire clip t o arrive in t he user’s browser, t he clip begins playing af t er a f ew seconds. As t he user wat ches or list ens t o t he clip, t he rest of t he clip loads in t he background.

    Table 19- 2 lists three co mmo n video fo rmats yo u’ll run acro ss as yo u create Web pages. They all play video co ntent that includes mo tio n and so und. As with the audio fo rmats, yo ur users must have the appro priate players to play these files.

    Part I V— Sat urday Evening Session 1 9

    If so und adds po unds to a Web page, video adds to ns. Even sho rt video clips co n-

    254

    Sat urday Evening

    Fo rtunately, these video fo rmats are beco ming so co mmo n that mo st users have players installed that will take over when such a clip is lo aded in the browser.

    Table 1 9 -2 Co mmo n Vide o Fo rmats

    Name

    Exte nsion

    AVI

    .avi

    MPEG

    .mpg and .mpeg

    QuickTime

    .mov

    Two fo rms of Web page video exist. They are external video and internal video .

    Specifying ext ernal video clips An external video clip is a clip that plays, when the user selects the appro priate link, using a pro gram that is external to the browser. Fo r example, when an external QuickTime video clip is requested, the browser idles while the user’s QuickTime player pro gram auto matically starts and plays the video sent to it. When the user clo ses the player window, the Web page appears o n the screen in the same state it was in befo re the user clicked the link, except that the link’s co lo r will now reflect the fact that the link has been visited. To specify an external video , simply hyperlink to the video file. The user’s browser is respo nsible fo r sending a request to the o perating system to start the external player that will play the clip. Here is so me HTML co de that pro duces such a clip by inserting a link to the AVI file:


    This window video (1.02 Meg AVI, 11 seconds) shows the many analogies between the physical
    windows you open and close and your operating windows. When the user selects the clip, the user’s default player fo r that video fo rmat begins, as shown in Figure 19- 2.

    Session 1 9 — Act ivat ing Pages wit h Mult imedia and Rollovers

    255

    Figure 19-2 Whe n the use r clicks the vide o ’s hype rlink, the e xte rnal playe r be gins.

    As with all hyperlinks, yo u can make an image a link as well as text. Perhaps a still image fro m the video wo uld make a go o d hyperlink because it offers a preview of the clip the user is abo ut to see.

    Specifying int ernal video clips Instead of letting an external video player begin, yo u can specify that the video play directly inside yo ur Web page. Altho ugh the AVI video fo rmat is the fo rmat best suppo rted, mo st of to day’s browsers suppo rt the o ther video fo rmats as internal video clips as well. When yo u specify an internal video clip, yo u can co ntro l the fo llowing aspects of the video :

    쐌 The lo catio n of the video play 쐌 Whether o r no t the video begins as so o n as the page lo ads o r o nly when the user clicks the Play butto n

    Part I V— Sat urday Evening Session 1 9

    Not e

    Many browsers will not inst ant ly st art t he clip but will give t he user a chance t o save t he clip inst ead of opening, or running, t he clip. Rarely, comput er viruses can reside inside mult imedia format , alt hough clips f rom known Web sit es should be saf e t o load. By saving t he clip, t he user can bet t er cont rol how t he clip plays.

    256

    Sat urday Evening

    쐌 Whether the video repeats co ntinuo usly o r plays o nly o nce 쐌 The width and height of the embedded video player The tag co ntro ls the internal playback of AVI video s. As a matter of fact, the tag is useful fo r embedding any file of any type in a Web page, but the file is to remain hidden unless the browser has the co rrect plug-in, a helper applicatio n pro gram that can o pen files of that type. Mo st mo dern browsers have ample plug-in suppo rt fo r all the po pular multimedia file types described in this sessio n, but no t all users use mo dern browser versio ns that suppo rt all these files. Therefo re, use with discretio n.

    Not e

    The t ag is a st andard t hat began wit h HTML 4 t hat enables you t o embed a f ile of any t ype in a Web page; if t he proper plug- in is available, t hat f ile will act ivat e properly. The t ag is bet t er support ed, however, by Net scape and I nt ernet Explorer, st ill t he t wo most popular browsers.

    Listing 19- 2 co ntains a simple but co mplete Web page that plays a video clip internally.

    Listing 1 9 -2 Embe dding a vide o inside the We b page

    Mastering Windows 98

    Windows 98 Tutorial The Start-up Once you start a computer running Windows 98, the computer performs a self-test and then
    Windows 98 loads. Toward the end of the loading, you’ll hear the Windows 98

    Session 1 9 — Act ivat ing Pages wit h Mult imedia and Rollovers

    257

    Figure 19- 3 shows the Web page that results fro m Listing 19- 2’s HTML co de. If yo u do n’t want the video to start until the user clicks the Play butto n, set the

    autostart= attribute to false. If yo u want the video to play o nly o ne time, set the loop= attribute to false. One final attribute, hidden=, determines whether the user sees the video o r o nly hears the so und. Because yo u can embed files of any data type using , yo u can embed a so und file with and set the

    hidden= attribute to true to hide the audio player but still permit the user to hear the audio .

    Part I V— Sat urday Evening Session 1 9

    start-up sound.

    Familiarizing Yourself With Window Operations

    The beauty of a windowed environment is that this environment uses familiar terminology. You open a window,
    you close a window, you select one of the window’s panes.

    As you learn the process of window management, consider how you work with windows in the real world.






    Co ntinue d

    Part I V— Sat urday Evening Session 1 9

    Yo u can now create a Web page that is a simple page co ntaining o nly the single but-

    262

    Sat urday Evening

    Listing 1 9 -3

    Co ntinue d













    No tice that the co de sto res each of the two images, and then the event, in the bo dy of the co de, swaps the butto n with its o ppo site image. The changeIt ro utine requests that the butto n named Interests be swapped with the o ther image. Yo u might also no tice that JavaScript appears co mpletely inside co mments. Therefo re, any o lder browsers will igno re the JavaScript and will just display a regular butto n. Older browsers also igno re unreco gnized attributes, such as the ONMOUSEOVER and

    ONMOUSEOUT events.

    Session 1 9 — Act ivat ing Pages wit h Mult imedia and Rollovers

    Tip

    265

    “ How am I supposed to know what to code?” you may be asking. When your Web page contains ten buttons, what do you do differently? The answer is, start with this code and simply add to it. Where this code stores two button images, your code will store ten pairs of images. This code is the skeleton for most of the rollover effects in use today. Don’t expect to decipher and understand every line of the preceding JavaScript. I t is the foundation for future expansion as you learn more about JavaScript and DHTML.

    REVI EW 쐌 Altho ugh bandwidth is increasing, limit yo ur use of multimedia to present fast- lo ading Web sites.

    쐌 Yo u can add so unds with the simple hyperlink tag. 쐌 So und and video clips sho uld be sto red in their own directo ries to limit the multiple lo ading of the same file that appears several times o n a site. itself.

    쐌 Ro llover effects help to activate yo ur page with DHTML.

    QUI Z YOURSELF 1.

    Name two po pular audio fo rmats fo r Web use. ( See “Adding So und to Web Pages.” )

    2.

    True o r False: The user can start and sto p a so und yo u embed in a Web page using the tag. ( See “ So und with HTML.” )

    3.

    What is the difference between a Web page video and a Web page streaming video ? ( See “Adding Video to Web Pages.” )

    4.

    What is the difference between external video and internal video ? ( See “Adding Video to Web Pages.” )

    5.

    What language suppo rts ro llover effects? ( See “ The Ro llover Effect.” )

    Part I V— Sat urday Evening Session 1 9

    쐌 Video clips can request an external player o r appear inside the Web page

    SESSI ON

    20 Be Uniform wit h St yle Sheet s

    Session Checklist ✔ Learn why style sheets are needed and their advantages and disadvantages 쐌 Learn the fo rmat of a style in a style sheet and the mo st po pular styles 쐌 Prepare a style sheet fo r an individual Web page o r o ne fo r an entire site 쐌 Perfo rm advanced wo rk with styles, such as specifying classes

    I

    n this sessio n, yo u learn how to fo rmat using an appro ach that differs fro m the individual fo rmatting yo u’ve learned so far. Yo u learn how to fo rmat with style sheets. Style sheets sho uld revo lutio nize the way pro grammers write

    HTML co de. In this sessio n, yo u learn the why and how of style sheets. Altho ugh yo u wo n’t learn every style sheet detail, yo u will begin to see why style sheets pro mise to change the way pro grammers create Web pages in the future.

    268

    Sat urday Evening

    I nt roducing St yle Sheet s Perhaps yo u’ve used styles in wo rd pro cesso rs. When yo u create a style fo r a paragraph, fo r example, yo u specify that paragraph’s margins, fo nts, and spacing, as well as any o ther details yo u want that paragraph style to achieve. Yo u name the style fo r easy reference. Then any paragraphs yo u later write will take o n that style’s requirements when yo u apply the paragraph style’s name to tho se paragraphs. By defining a style o nce, yo u do n’t have to reissue the same fo rmatting co mmands every time yo u want that style. Yo u o nly need to begin writing witho ut regard to any fo rmatting. When yo u finish, yo u then apply the style, and the wo rd pro cesso r fo rmats the paragraph pro perly. HTML suppo rts style sheets as well. The HTML style sheets are called Cascading Style She e ts ( o r CSS) , and they wo rk in a manner similar to tho se in yo ur wo rd pro cesso r.

    Before you cont inue . . . Befo re this sessio n co ntinues, please understand that the analo gy between wo rd pro cesso r style sheets and HTML style sheets is an imperfect o ne at best. Whereas mo st wo rd pro cesso rs are WYSIWYG ( What Yo u Se e Is What Yo u Ge t, which is the co ncept that the screen lo o ks like the finished, printed pro duct will lo o k) , mo st HTML style sheets do no t represent what appears o n the final user’s screen. HTML’s style sheets are merely reco mmendatio ns to the end- user’s browser as to how to fo rmat the Web page. This is because of the vast array of Web viewing equipment o n the market. Yo u can create a fantastic heading style that wows the masses when yo ur screen is the o nly game in town, but co nsider a list of just so me of the hardware that users may use to view yo ur Web page:

    쐌 A 21-inch, high-reso lutio n, plasma, flat-panel, 1200 × 1024 pixel, 16-millio n co lo r mo nito r

    쐌 A 15- inch, 640 × 480 pixel, 256- co lo r mo nito r 쐌 WebTV 쐌 Black- and- white po rtable Internet- ready displays, such as cell pho nes, that display 40 characters per line and up to 10 lines of a Web page at any o ne time befo re requiring scro lling ( such screens co me o n devices called PDAs, Pe rso nal Data Assistants )

    With such an array of hardware, how applicable is yo ur style that defines a paragraph as a bo ldfaced blue Times Ro man 12- po int fo nt who se first line is indented 5 characters, with a maximum line width of 80 characters? Yo u have

    Session 2 0 — Be Uniform wit h St yle Sheet s

    269

    abso lutely no assurances that the target browser will be able to respect yo ur style wishes. Yet, yo u canno t throw o ut Web page material witho ut any fo rmatting, right? Yo u have the cho ice of applying all the individual fo rmatting co mmands yo u’ve learned so far, applying a style sheet to yo ur page, o r co mbining the two .

    Why use st yle sheet s Style sheets have had so me impact o n HTML co ding but have a lo ng way to go . Just abo ut everybo dy agrees that style sheets are necessary to ensure a site’s co nsistency and maintainability. The pro blem is that no t all browsers suppo rt styles and style sheets themselves are go ing thro ugh a maturatio n phase, having two sets of standards: CSS1 ( o r CSS Level 1) and CSS2 ( o r CSS Level 2) . Until the style sheet standard settles a little mo re, and until HTML pro gramming handles style sheets mo re co nsistently, the use of style sheets will remain mo re theo ry than practice. Nevertheless, yo u must maintain pro per co ding techniques, and to do so , yo u need to understand style sheets and how they benefit yo u as yo u do HTML pro gramming. Depending o n yo ur audience, yo u may want to offer yo ur entire site a browser versio n that suppo rts style sheets, it is safe to use them and yo u are enco uraged to use style sheets. A co mpany- wide style sheet helps ensure that yo ur co mpany’s Web pages remain co nsistent. Ano ther reaso n to learn abo ut style sheets is that they are a part of HTML and are growing with each new release. HTML 4.01 suppo rts bo th the CSS1 and CSS2 standards of style sheets, and in the future, no browser is likely to be released that do es no t co nfo rm to these standards. As the wo rld begins to use styles mo re, so will yo u.

    The added advant ages of CSS To wrap up the CSS intro ductio n, co nsider this list of features and advantages:

    쐌 Yo u can speed the fo rmatting of yo ur Web pages by defining a style in o ne place and then applying that style to all Web page material that sho uld use it.

    쐌 Yo u can change the lo o k of yo ur entire Web site by changing o nly the style sheet’s styles.

    쐌 Style sheets suppo rt fo rmatting that straight HTML do es no t suppo rt. Fo r example, yo u can remove the auto matic underlining fro m hyperlinks and place text and graphics at an exact pixel po sitio n o n the page.

    Part I V— Sat urday Evening Session 2 0

    with style sheets. If yo u write fo r a co mpany’s intranet that has standardized o n

    270

    Sat urday Evening

    쐌 Yo u can save time when creating new pages fo r yo ur Web site if it has its fundamental styles defined.

    쐌 Yo u can create a style sheet fo r an individual page o r fo r all the pages o n o ne Web site.

    I nt roducing HTML St yles Just abo ut any fo rmatting yo u’ve already mastered has a style sheet equivalent. In style sheet termino lo gy, yo u’ll be specifying characte ristics as o ppo sed to the attributes yo u specify when issuing individual tags. The fo rmat of the typical style and so me of the po pular style characteristics are covered in this sectio n.

    Typical st yle format Here is the fo rmat of the typical style: Tag { characte ristic1 ; characte ristic2; . . . ; characte risticN}

    Here is a sample tag:

    h1{font-family: “Arial”, “Schoolbook”; color: blue} The tag is the primary heading tag that yo u’ve already mastered. The characteristics ( yo u can list as many as yo u need to list) fo llow the tag inside the braces. This style says that all h1 tagged paragraphs in the page ( o r o n the entire site depending o n how yo u set up the styles) are to use the Arial fo nt, and if that’s no t available, a fo nt named Scho o lbo o k. In additio n, the seco nd characteristic states that all h1 text is to be blue. Any characteristics of the tag that yo u do no t explicitly state will take o n the tag’s default characteristics. Therefo re, text fo rmatted with this attribute will be bo ldfaced because no rmally bo ldfaces the heading text and the style do es no thing to override that bo ldfacing. That’s really all there is to creating styles. The remaining sectio ns of this sessio n explain how to apply the styles to a Web page o r to yo ur entire site, and explo re mo re ways to present the styles.

    Useful st yle charact erist ics As previo usly no ted, just abo ut any fo rmatting yo u’ve already mastered has a style sheet ( o r style sheet characteristic) equivalent. In this sectio n, yo u’ll learn the mo re po pular style characteristics.

    Session 2 0 — Be Uniform wit h St yle Sheet s

    271

    To align text, use the text-align characteristic. Each of the fo llowing styles aligns a headline level differently. ( By the way, this is fo r illustrative purpo ses o nly; do n’t try this at ho me! Giving the first fo ur headline styles fo ur different alignments wo uld lo o k disastro us at best and is likely to lo se visito rs to yo ur site.)

    h1{text-align: h2{text-align: h3{text-align: h4{text-align:

    left} center} right} justify}

    Yo u can change the we ight of a fo nt, meaning yo u can use the font-weight characteristic to apply bo ldfacing to a fo nt of a no rmal, no nbo ldfaced weight o r apply no rmal weight to a fo nt that is already bo ldfaced by default. The first of the next two styles removes the bo ldfacing no rmally fo und o n the h1 ( heading) fo nt, and the seco nd style applies bo ldfacing to the p ( paragraph) style:

    h1{font-weight: normal} p{font-weight: bold}

    To italicize text, use the font-style characteristic like this:

    h1{font-style: italic} p{font-style: italic}

    Not e

    Even t hough t hese examples specif y only one charact erist ic at a t ime for each st yle, you can combine as many as you want , separat ing t hem wit h semicolons. I show only one at a t ime here so t hat you can more easily focus on each new charact erist ic.

    Change the size of the fo nt by specifying the font-size characteristic. Yo u can specify an exact fo nt size like this:

    p{font-size: 14} Yo u can also specify a relative fo nt size using o ne of these characteristics:

    xx-small, x-small, small, medium, large, x-large, and xx-large. The fo llowing

    Part I V— Sat urday Evening Session 2 0

    Not e

    Remember t hat all unspecif ied default charact erist ics will apply unless you override t hem. Therefore, t he t ag will appear wit h a normal weight due t o t he st yle but will st ill be in a large t ypeface because t he t ag will normally display it s informat ion in t he large t ypeface.

    272

    Sat urday Evening

    styles each specify o ne of the seven relative fo nt sizes, which let the user’s browser resize the text o n the page:

    p1{font-size:xx-small} p2{font-size:x-small} p3{font-size:small} p4{font-size:medium} p5{font-size:large} p6{font-size:x-large} p7{font-size:xx-large}

    Never

    Never, as a rule, specif y a st yle wit h an exact font size if you want t o please all your users all t he t ime. Most of t oday’s browsers enable t he user t o increase or decrease t he t ext size on t he page. The browsers might ref use t o change any font size for which you’ve specif ied t he exact point size. However, t hey of t en resize specif ied relat ive font sizes.

    To specify a named text co lo r, use the color characteristic like this:

    h1{color: blue} h2{color: red} In additio n to the named co lo rs, yo u can also specify any co lo r using a hexadecimal number such as this:

    h1{color: #00cc00} As yo u saw in the previo us sectio n, yo u can specify o ne o r mo re fo nt names yo u want the browser to cho o se fro m. The browser begins at the first fo nt o n the left and go es down the list, fro m left to right, until the browser sees a fo nt that it reco gnizes. If all fo nts in the style are unavailable o n the user’s machine, the browser do es its best to guess, which is no t always well. Use the font-family characteristic to specify o ne o r mo re fo nts as fo llows:

    h1{font-family: “Arial”, “Schoolbook”} To specify the maximum width of a style’s paragraph, use the width characteristic fo llowed by a pixel value, like this:

    p{width: 400px}

    Session 2 0 — Be Uniform wit h St yle Sheet s

    273

    Yo u can also specify bo th the width and height of all images that use a specific tag with the width and height characteristics, like this:

    img{width: 320px; height: 240px} Yo u can use the line-height characteristic to specify the exact line height, in pixels, like this:

    body{line-height: 12px} A nice style that often co mes in handy where the regular fo rmatting co des do n’t wo rk well is paragraph indentio n. Use the text-indent characteristic to specify the paragraph’s first line indentio n. Yo u can specify the indentio n in exact pixels ( px) , inches ( in) , centimeters ( cm) , millimeters ( mm) , o r po ints ( pt) , o r else as a percentage ( %) . The percentage ensures that yo ur paragraph indents well no matter how wide the user’s browser screen appears.

    body{text-indent: 3%} The margin-left, margin-right, and margin-top characteristics determine right margins to the same width, use the margin characteristic, like this:

    body{margin: 12pt} Yo u’ve now seen the general fundamentals of styles that yo u can specify. Yo u now need to learn how to prepare the style sheet fo r use. The last ten minutes of this sessio n will then explo re the mo re advanced characteristics that yo u can use.

    Preparing One of Two St yle Sheet s Keep in mind that HTML suppo rts two style sheets: a style sheet fo r an individual Web page and o ne fo r an entire site. When yo u create a style sheet fo r a single Web page, yo u define the styles inside that page in the header sectio n. When yo u create a style sheet fo r an entire site, the style sheet must reside in an external central lo catio n so that all the Web pages can link to the styles.

    Part I V— Sat urday Evening Session 2 0

    how wide the margins aro und the text will be. If yo u want to set bo th the left and

    274

    Sat urday Evening

    Tip

    Generally, linking t o an ext ernal st yle sheet is bet t er sit e design t han embedding st yles inside each page. The single, linked st yle sheet put s all your sit e’s st yles inside one locat ion for easy access. Nevert heless, if a Web page does cont ain a special st yle element not found in any ot her page on t he sit e, you might embed t hat single st yle in t hat one Web page. The st yle won’t clut t er t he sit e’s ext ernal st yle sheet . I f , however, t hat st yle ult imat ely needs t o appear on more pages, move t he embedded st yle t o t he linked st yle sheet .

    The next few sectio ns explain bo th ways to set up the styles.

    St yle sheet s for individual Web pages Place yo ur styles in the header sectio n of the Web page yo u want tho se styles applied to . Begin with the end tag befo re co mpleting the header sectio n. The fo llowing co de illustrates such a header sectio n:

    Family Reunion

    Type the co mment exactly as yo u see it here, and the browsers will fo llow o r igno re the styles as needed.

    One st yle sheet for mult iple Web pages As yo u surf thro ugh po pular Web sites, co nsider why they are po pular. Almo st all the po pular, mo st- visited sites have these elements in co mmo n:

    1.

    They co ntain needed info rmatio n o r provide an enjoyable diversio n.

    2.

    They lo ad quickly.

    3.

    They retain a co nsistent lo o k thro ugho ut the site.

    Part I V— Sat urday Evening Session 2 0

    Family Reunion

    276

    Sat urday Evening

    One of the ways to achieve site co nsistency is to develo p a style sheet fo r the entire site. Once yo u do , each Web page can then use tho se styles in a unifo rm manner.

    Tip

    Consider how much less clut t ered your HTML code will be when you adopt st yle sheet s. I nst ead of wading t hrough all t hose t ags and at t ribut es, you can maint ain all t he st yles in a single locat ion, t he rest of your pages cont aining primarily t ext and graphic element s. When you make changes t o t he sit e, such as updat ing some of t he t ext , you won’t be bot hered wit h as many t ags. When you add new t ext , grab one of t he appropriat e predef ined st yles in t he st yle sheet t hat you have already set up.

    To create a single style sheet fo r yo ur site, yo u o nly need to create a text file and add the styles. Do no t include tags. A file that defines styles such as tho se presented at the end of the previo us sectio n might lo o k like this:

    h1{font-family: “Arial”, “Schoolbook”; color: blue} p{font-family: “Arial”; color: black} As yo u can see, the file is simple. Yo u must save the file with the .css filename extensio n, such as salesite.css; the name befo re the extensio n can be any legal filename. In each Web page that is to use the .css file’s styles, yo u must link the header sectio n to the style sheet file. Do n’t use the



    Session 2 3 — The Web Sit e Home Page’s HTML

    311

    Window title goes here





    Document t he HTML Code purpo se of the HTML file, co ntains yo ur name and co ntact info rmatio n ( especially if yo u wo rk o n a team that is develo ping several Web pages, so that o ther team members can co ntact yo u when they need to link to yo ur set of pages) , and includes the date of the initial HTML design. This do cumentatio n will help bo th yo u and o thers who may edit yo ur Web page’s HTML. In a printed listing of several HTML Web pages, the co mments will enable yo u to determine which listing pro duces which Web page.

    Never

    Never include cont act informat ion t hat you don’t want ot hers t o know about , because your Web page’s HTML source code is available for ot hers. I f you develop Web pages for your company’s int ranet , and your pages remain wit hin t he company’s servers, document your name and cont act informat ion so t hat ot hers in t he company can locat e you if a change must be made. I f your sit e goes out t o t he ent ire World Wide Web, do not reveal personal cont act informat ion. Your company’s physical mailing address is appropriat e t o include, however, so t hat ot hers can writ e t o t he company about t he sit e.

    Part V— Sunday Morning Session 2 3

    Add initial do cumentatio n to the co de ( in the fo rm of co mments) that explains the

    312

    Sunday Morning

    Generally, yo u’ll provide so me way o n the Web page fo r users to co ntact yo u ( e.g., yo ur e- mail address and public pho ne numbers) . With perso nal Web sites, an e- mail address is generally the o nly co ntact info rmatio n that yo u need to provide. The Barkleys didn’t want to put their pho ne number o r address in their HTML co de fo r the Web site because the site is intended fo r enjoyment by family and friends and they will be the o nly peo ple mo difying the co de. Nevertheless, they understand the purpo se of go o d do cumentatio n, as well as go o d meta tags that may get their site fo und by a search engine. Their initial HTML co de, befo re adding any specific Web page tags, appears in Listing 23- 3.

    Listing 2 3 -3 The Barkle ys’ starting HTML co de





    The Barkley Family Web Page



    Session 2 3 — The Web Sit e Home Page’s HTML

    313



    St art ing t he Header Table The header sectio n of the Barkley ho me page will co ntain the to p table o n their page; it will to p the o ther pages o n the site as well. Yo u might want to reference Figure 22- 3 in the previo us sessio n, where the Barkleys used a graphics pro gram to lay o ut their ho me page and draw the table guidelines fo r two tables: o ne fo r the header and the o ther fo r the ho me page co ntents. Figure 23- 1 shows the finished header sectio n, which is the go al of this sectio n and the sectio n o n co mpleting the header, which immediately fo llows.

    Part V— Sunday Morning Session 2 3

    Figure 23-1 A table de fine s the We b page ’s he ade r se ctio n.

    The elements of the header all fo rm a table. The table is beneficial because it enables the Barkleys to add elements, change the artwo rk, and add mo re links at

    314

    Sunday Morning

    the to p of the page easily by inserting these items in cells, adding new cells, and resizing cells that need to be resized. Witho ut the table’s fo rmat, mo difying o ne item in the header may negatively affect the fo rmatting of the o ther items, and simple changes will beco me difficult.

    The added benef it of t he t able- based header is t hat t he header’s colors and lines can span t he user’s screen no mat t er what t he screen widt h is. Not e

    The header shown in Figure 23- 1 co ntains five rows and three co lumns. No t all the co lumns will be used o n each row, but the three co lumns enable yo u to align all the data pro perly. Fo r example, the first row co ntains o nly the hyperlink Home. On subsequent pages, Home will fo rm a link back to this page. On this page, the link simply relo ads the current page.

    Not e

    Some Web mast ers ut ilize links such as t his Home link on every page in a Web sit e, but t hey leave t he link dead on t he home page ( meaning t he t ext appears but no hyperlink is def ined) . Clicking a dead link keeps you on t he same page, but clicking t he link on subsequent pages ret urns t he user t o t his home page. I f you def ine t he link, even on t he home page, t he page will reload, showing t he user t he purpose of t he word. I f t he user clicks on t he link but not hing happens, t he user may not know t o click t he link on subsequent pages where t he link is act ive. Therefore, consider act ivat ing all links, even same- page links.

    The seco nd row is a thin strip of white that separates the first and third rows. Table rows are rarely the same height except when they co ntain numerical data in a spreadsheet- like fo rmat. The third row in the header table mo re o bvio usly shows the three cells that make up the header. The cells will ho ld, fro m left to right, the family lo go , the mailbox ( which is a hyperlink to the family’s e- mail address in case anybo dy clicks the mailbox) , and a go ld- co lo red message that the Barkleys can easily change by altering the co ntents of the cell.

    This t ut orial’s CD- ROM cont ains all t he graphic images used in t he Barkley Web sit e. Cross-Ref

    Two mo re rows in Figure 23- 1 co ntain two additio nal lines: o ne white and o ne go lden. The go lden text and lines wo rk well with the green backgro und of this Web

    Session 2 3 — The Web Sit e Home Page’s HTML

    315

    site. Yo u wo n’t be able to distinguish the bo tto m two lines very well in this text’s figures, but if yo u fo llow alo ng and create the HTML, yo u will see how well the co lo rs wo rk to gether. To create the initial table, the Barkleys used the fo llowing co de:

    Online Investing or Betting?

    Are your odds better when you send money to your discount broker than when you throw the dice at the Vegas tables?

    The table will span 100 percent of the user’s screen witho ut any padding o r spacing between the cells o r any bo rder lines aro und the table. The table’s cell backgro und co lo rs will be green ( #009900) unless overridden with a bgcolor= attribute set in o ne of the table’s tags. Browsers determine a lo t fro m a table by scanning the co mplete set of co mmand tags fro m
    o r
    to
    . If the first row co ntains a single cell but the third row co ntains three cells, the entire table will be assumed to have three cells. Given that this page’s header will require three cells in the third row ( the row with the lo go ) , yo u might as well co de the two extra cells o n the first row of the table. Do ing so makes it mo re o bvio us that the table co ntains three cells per row. The fo llowing co de defines the first row with the Home link:

    The thin separating line between the first row and the third is specified in this co de:



    Home


         

    Co ntinue d

    318

    Sunday Morning

    Listing 2 3 -4

    Co ntinue d







         



        All the news


    Session 2 3 — The Web Sit e Home Page’s HTML

    319

     that’s new for you






    320

    Sunday Morning

    쐌 The header is often a table that spans the user’s entire screen width. 쐌 Co ntact info rmatio n in a header hyperlink enables users to co ntact yo u abo ut yo ur site.

    QUI Z YOURSELF 1.

    What can happen if yo u place undivided co mments thro ugho ut the sectio ns of an HTML Web page? ( See “ The Initial HTML Template.” )

    2.

    Why sho uld yo u no t always include yo ur address and pho ne number in the o pening co mment sectio n of yo ur Web page? ( See “ Do cument the Co de.” )

    3.

    What width advantage can a table provide fo r the header? ( See “ Starting the Header Table.” )

    4.

    What is an advantage to activating same- page hyperlinks? ( See “ The To p Table.” )

    5.

    Why do yo u often see no nbreaking spaces scattered thro ugho ut HTML co de? ( See “ Co mpleting the Header Table.” )

    SESSI ON

    24 The Web Sit e Home Page’s Text and Graphics

    Session Checklist ✔ Understand the table that creates the Barkleys’ ho me page co ntents ✔ Create the Barkleys’ navigatio n bar fro m a table ✔ Remember to create simple Web ho me pages ✔ Create the Barkleys’ thumbnail images and text fro m a table

    I

    n this sessio n, yo u co ntinue building the Barkley family ho me page that yo u began in the previo us sessio ns. The page is co ming alo ng nicely. Here, yo u’ll put the header that is now co mplete at the to p of all the site’s Web pages, and

    yo u’ll add so me new elements as well. The rest of the ho me page includes a single table that ho lds the navigatio n bar and the primary page’s co ntent. If yo u are fo llowing alo ng, lo ad the HTML co de that yo u created fro m the previo us sessio n and begin.

    322

    Sunday Morning

    The Home Page’s Bot t om Table As no ted in the previo us sessio n, the Barkley ho me page co nsists of two tables: o ne fo r the header and the o ther fo r the navigatio n bar and the co ntents. The graphics pro gram mark- up lines, repeated in Figure 24- 1, show the three cells of the lower table and how the cells ho ld and help place and align their co ntents. The three cells co ntain the navigatio n bar, thumbnail images, and text.

    Figure 24-1 The table ’s ce lls e nable yo u to manage a We b page mo re e asily.

    Altho ugh the Barkleys cho se white o n green letters fo r the heading and the navigatio n menu down the left side of the page, they wisely decided o n a white backgro und fo r the central co ntent’s table backgro und co lo r. All the Web site’s co ntent appears in this large, central area. No thing wo rks better than a white backgro und. Other co lo rs will make yo ur users hesitate so mewhat because the eye do es no t adjust well to many text and backgro und co lo r co mbinatio ns. So me co lo r co mbinatio ns can slow the reading of a Web page by 10 percent o r mo re. To be safe, use a white backgro und.

    Session 2 4 — The Web Sit e Home Page’s Text and Graphics

    Not e

    323

    Make sure t hat your t able background colors mat ch t hose of t he Web page’s background on which t he t ables lie or t hat t he t ables are as wide as t he ent ire Web page. Ot herwise, t he browser will leave a border around t he out side of your t ables. For example, Figure 2 4 - 2 shows what happens when t he Web page’s background color is whit e but t he heading is green. Because t he header’s t ables do not t ake t he widt h of t he Web page, t he page’s whit e background creat es a whit e border around t he heading. By specif ying a green page background, t he heading and ot her t ables are not out lined.

    Do n’t o utline yo ur he ade r table by spe cifying a diffe re nt bo dy backgro und co lo r.

    The fo llowing statement defines the table that co mprises the bo tto m of the ho me page:



    Part V— Sunday Morning Session 2 4

    Figure 24-2

    324

    Sunday Morning

    Why isn’t a width of 100 percent used, as was used fo r the header table in the previo us sessio n? Pro blems so metime arise with percentage width measurements in tables. The left-hand table co lumn is squeezed down to fit any o ther co lumns who se widths are specified in pixel measurements. In o ther wo rds, the center co lumn of the table must be exactly 105 pixels to ensure that eno ugh ro o m appears fo r the thumbnail pictures the Barkleys want to put befo re mo st of their anno uncements o n the ho me page. Given that this co lumn is a fixed width, the 100 percent wo uld mean that the browser wo uld adjust o ther co lumns if necessary. It wo uld turn o ut that the browser wo uld adjust the left co lumn in this situatio n, making the navigatio n bar thin and squeezed and messing up the spacing of the text. By specifying all three co lumns by an exact pixel measurement, and by keeping the to tal width less than the screen size of mo st co mputers in use to day, yo u can keep yo ur co lumns an accurate size. By giving the far right table a width of 2,000 pixels, yo u ensure that the heading will fill the entire Web page no matter how great the user’s screen reso lutio n is. Remember that this bo tto m table begins the bo dy of the ho me page. The header sectio n ho lds the table that yo u created in the previo us sessio n.

    The Navigat ion Bar This Web page’s navigatio n bar wo uld have been a great use of a frame; the window with the navigatio n bar remains o n the screen while the user scro lls the co ntent in the large window. Yo u already know the frame feature’s pro blems and limitatio ns. Given the pro blems with frames, such as the fact that so me browsers still in use do n’t even suppo rt frames, the Barkleys decided that their ho me page sho uld stick with tables, which have been aro und since the first versio n of HTML. Fo rtunately, the Web page lo o ks much better witho ut the frame.

    Not e

    Except in ext remely advanced sit es developed by graphics and Web specialist s, f rames can make even a good sit e look amat eurish. Not all sit es t hat use f rames look amat eurish, but f rames add an element t hat det ract s f rom almost any page.

    The cell o n the left of the page’s bo tto m table will ho ld the navigatio n area fo r the page. The left co lumn co nsists of a single cell. This cell must span three rows because the rest of the page uses three rows by design; the Barkleys want their to p two messages to their friends and family to appear in the large co ntent area of the bo dy and o ther no tes to appear thro ugho ut o ther pages o n the site.

    Session 2 4 — The Web Sit e Home Page’s Text and Graphics

    325

    The Barkleys are wise to keep their ho me page text to a minimum. The rather large header already co nsumes much of the site. Altho ugh the header is no t o ne that overshadows their co ntent, the Barkleys must keep the co ntent o n the ho me page simple and let the navigatio n bar take users to mo re detailed po ints of interest. Listing 24-1 shows the navigatio n bar po rtio n of the bo dy. The cell is the first cell in the row, so a tag must info rm the browser that a new row is beginning.

    Listing 2 4 -1 Cre ating the navigatio n bar’s co de

    The ( ho rizo ntal rule) tags draw a ho rizo ntal ruler line acro ss the cell. To separate the two large sectio ns of the navigatio n bar, the Barkleys used two ho rizo ntal rules. The first sectio n, the Welco me sectio n, will remain fairly static, and the Barkleys have no plans to change the structure. The seco nd sectio n, the Special Bulletins sectio n, may ho ld fro m o ne to 10 items depending o n how impo rtant the family co nsiders each new item to be. As it stands now, o nly o ne Special Bulletin, the recent family travels, appears in the navigatio n bar’s seco nd sectio n. The rowspan=3 attribute info rms the browser that this cell is to extend as far down as needed to ho ld its co ntents. Witho ut the rowspan=3 attribute, the browser wo uld make the rest of the navigatio n bar o nly as wide as the first cell. Figure 24- 3 shows the Barkleys’ ho me page as it now appears.

    Part V— Sunday Morning Session 2 4



    326

    Sunday Morning

    Figure 24-3 The navigatio n bar spans thre e rows to e xte nd down the page.

    Obvio usly, the navigatio n bar requires links to pages. In the next sessio n, yo u will add hyperlink ancho r tags to each of the navigatio n entries.

    The Final Two Columns: I mages and Text The two final co lumns are rather simple to add. The middle co lumn’s primary jo b is to ho ld thumbnail images the Barkleys will use next to their ho me page anno uncements. In additio n, to make heading text run acro ss the to p of the center co lumn’s graphic and into the third co lumn where mo st of the text co ntent lies, the middle co lumn will ho ld the first few letters of the headings, as yo u’ll see here. The two co lumns of cells in the white, co ntent sectio n finish o ut the three co lumns that the bo tto m table displays. In o ther wo rds, the large sectio n below the heading is just a three- co lumn table, with the first co lumn being the navigatio n bar and the seco nd and third ho lding co ntent. Listing 24- 2 co ntains the co de fo r the to p cell in the first row of the middle co lumn. It ho lds the thumbnails and so me heading text.

    Session 2 4 — The Web Sit e Home Page’s Text and Graphics

    327

    Listing 2 4 -2 Cre ating the to p ce ll in the table ’s first row

    The key po ints to Listing 24- 2 are simply that the backgro und co lo r is now white ( bg=white) and the cell’s co ntents are aligned vertically to the to p of the cell ( valign=top) and ho rizo ntally ( align=right) to the right so that the headline text can be co ntinued into the next cell. Finish entering the text in the third cell befo re viewing the page. Listing 24- 3 co ntains the co ntents of the third cell.

    Listing 2 4 -3 Cre ating the third ce ll in the table ’s first row

    Figure 24- 4 shows the Barkleys’ ho me page as it now appears. The final cell helps fix the spacing pro perly fo r the page. The third co lumn maintains the white backgro und and co ntinues the go ld headline that began in the previo us co lumn.

    Part V— Sunday Morning Session 2 4



    328

    Sunday Morning

    The middle co lumn’s align=right attribute ensures that the text, Welcome to, appears above the graphic, and the third co lumn’s align=left attribute ensures that the remaining text, o ur family - Eight years in the making!, co mpletes the headline. By the way, the align=left attribute is the default alignment, but specifying it here helps show yo ur intentio n of merging the heading to gether and spanning two cells with the heading. The remaining text falls under the heading and uses no nbreaking characters to add so me needed spacing between the thumbnail pictures and the text.

    HTML programmers of t en break t ext across t able cells, st art ing in one and complet ing in t he next one. Not e

    Figure 24-4 The to p row of the navigatio n bar and co nte nt are a is now co mple te.

    The remaining two rows of the co ntent table are just mo re of the same. Fo rtunately, the same fo rmat and spacing are required, and yo u will fo rmat the remaining cells just as yo u did the cells in the first row. By keeping this structure, the Barkleys help keep their Web site co nsistent and familiar to users who view

    Session 2 4 — The Web Sit e Home Page’s Text and Graphics

    329

    the site o n a regular basis. Listing 24- 4 lists the rest of the page’s bo dy. Yo u sho uld have no tro uble understanding the rest of the co de.

    Listing 2 4 -4 Cre ating ce lls in the re maining two rows

    Co ntinue d

    Part V— Sunday Morning Session 2 4



    330

    Sunday Morning

    Listing 2 4 -4

    Co ntinue d

    Figure 24- 5 shows the co mpleted ho me page. No tice that each figure includes alternative text, with the alt= attribute, that appears even when the user’s browser’s graphics are

    Figure 24-5 Yo u’ve just co mple te d the layo ut fo r the ho me page.

    Session 2 4 — The Web Sit e Home Page’s Text and Graphics

    331

    The Barkleys are not using a foot er sect ion on t heir Web pages.

    Not e

    The Barkley’s ho me page will co ntain simple co lo rs, fo nts, and graphics that are no t overbearing. Yo u may be surprised to no te that the site uses o nly three co lo rs — green ( fo r the heading and navigatio n bar tables’ backgro unds) , go ld ( fo r the heading and greeting message) , and white ( fo r the ho me page co ntent table’s backgro und) — fo r its primary elements and layo ut. Only mino r exceptio ns here and there exist when the page’s graphic images utilize mo re co lo rs. Yo u are keeping the fo nts simple as well. The o nly fo nt used is Arial, and almo st all browsers that have ever been develo ped substitute a similar sans- serif fo nt if Arial is no t fo und. The lo go co ntains rather fancy text, po ssibly even to o fancy fo r the page so far, but it do es no t lo o k so do minant o nce yo u finish the ho me page, as yo u’ll do in the next sectio n. By keeping the ho me page simple, yo u do no t overlo ad the user’s eyes and yo u make the site welco ming.

    REVI EW 쐌 Maintain a high co ntrast between text and backgro und co lo rs to make yo ur site easy to read.

    쐌 Use the same table backgro und co lo r as yo ur Web page’s bo dy unless yo u 쐌 Utilize tables thro ugho ut yo ur site to help fo rmat yo ur Web page pro perly and co nsistently.

    쐌 Once yo u create the ho me page, co nnect the linked pages to it.

    QUI Z YOURSELF 1.

    What happens if the bo dy backgro und co lo r differs fro m yo ur table’s backgro und co lo r? ( See “ The Ho me Page’s Bo tto m Table.” )

    2.

    What part of the Barkley’s ho me page best lends itself to using frames? ( See “ The Navigatio n Bar.” )

    3.

    True o r False: The mo re fo nts yo u use, the fancier and mo re rich yo ur Web page lo o ks. ( See “ Simplicity Is the Key.” )

    Part V— Sunday Morning Session 2 4

    do n’t mind a bo rder appearing aro und yo ur tables.

    332

    Sunday Morning

    4.

    Why is Arial a safe fo nt to use a lo t? ( See “ Simplicity Is the Key.” )

    5.

    Altho ugh the center co lumn is primarily fo r graphic images, why do the Barkleys sto re so me text in that co lumn? ( See “ The Final Two Co lumns: Images and Text.” )

    SESSI ON

    25 Creat ing and Connect ing t he Web Sit e’s Pages

    Session Checklist ✔ Get the Barkleys’ Web site no ticed by search engines ✔ Turn the Barkleys’ lo go into a hyperlink to their ho me page ✔ Link the Barkleys’ thumbnail images to larger images ✔ Add hyperlinks to the Barkley ho me page’s navigatio n bar and create subsequent Web pages

    I

    n this sessio n, yo u co ntinue to ho ne the Barkleys’ ho me page by embedding meta tags to gain the attentio n of search engines and activating the ho me page’s links to the lo go and navigatio n bar. Yo u also learn how to create the

    links fro m the thumbnails to larger images as well as how to create the linked pages fo r the Barkley Mo m’s and Dad’s Web pages.

    Get t ing t he Barkleys’ Sit e Not iced by Search Engines The Barkleys o bvio usly intend that their friends and family view their site. In fact, they want their hard wo rk to be seen by as many peo ple as po ssible. Therefo re,

    334

    Sunday Morning

    they wo uld like fo r their Web site to appear inside search engine listings if po ssible. Altho ugh a family Web site usually do es no t warrant payment to a firm to advertise amo ng many search engines, and altho ugh such a Web site often do es no t even warrant registering with a single search engine if the registratio n co sts mo ney, yo u’re free to use meta tags in yo ur site’s HTML co de so that the site’s co ntent can be picked up and indexed by any search engine that no tices the site. To get the site seen by ro aming search engines and info rm them of its co ntent, the Barkleys embedded the meta tags ( ) shown in Listing 25- 1 into their ho me page at the to p of their site. The meta tags appear after the end tag but befo re the header table begins, as Listing 25- 1 shows.

    Listing 2 5 -1 Cre ating me ta tags to ge t the site no tice d by ro aming se arch e ngine s





    Welcome

    Mom’s Corner
    Dad’s Corner
    Kid’s Playground
    Family Pictures
    Favorite Movies

    Special
    Bulletins

    Family Travels



    Welcome to o



    ur family - Eight years in the making!


     Thanks for coming to visit our site.
     We want you to enjoy our family’s news.
     We’ll keep you up to date and provide plenty of pictures!

     (When you see a small picture, click it to see a larger version.)



    We’re movin



    g to the country!


     You’ve seen the Beverly Hillbillies and Green Acres. We’re trying
     to outdo both. We weren’t all that good at city living and we
     certainly don’t know anything (uh, I mean anythun’) about
     living in the country. But, we’re leaving our cityslicker house
     to live in the sticks. We love it here!
       - Photo by Shutterbug Mom



    Write us f



    or our new address!


     We don’t want to be omitted
     from your gift lists!

    The search engines, if they lo cate the Barkley Web site, will list the site as

    Barkley Family Web Site due to the meta tag name and co ntent attributes ( meta name=”description” content) . The meta tag keywo rd attributes (