P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 HTML, XHTML, and CSS Bible 3rd Edition Brian Pfaffenberger, Steven M. Schafer, Charles White, Bill Karow WileyPublishing,Inc. i P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 HTML,XHTML,andCSSBible,3rdEdition Publishedby WileyPublishing,Inc. 10475CrosspointBoulevard Indianapolis,IN46256 www.wiley.com Copyright(cid:2)C 2004byWileyPublishing,Inc.,Indianapolis,Indiana PublishedsimultaneouslyinCanada eISBN:0-7645-7718-2 ManufacturedintheUnitedStatesofAmerica 10987654321 Nopartofthispublicationmaybereproduced,storedinaretrievalsystemortransmittedinanyform orbyanymeans,electronic,mechanical,photocopying,recording,scanningorotherwise,exceptas permittedunderSections107or108ofthe1976UnitedStatesCopyrightAct,withouteithertheprior writtenpermissionofthePublisher,orauthorizationthroughpaymentoftheappropriateper-copyfee totheCopyrightClearanceCenter,222RosewoodDrive,Danvers,MA01923,(978)750-8400,fax(978) 646-8600.RequeststothePublisherforpermissionshouldbeaddressedtotheLegalDepartment,Wiley Publishing,Inc.,10475CrosspointBlvd.,Indianapolis,IN46256,(317)572-3447,fax(317)572-4355, e-Mail:[email protected]. LIMITOFLIABILITY/DISCLAIMEROFWARRANTY:THEPUBLISHERANDTHEAUTHORMAKE NOREPRESENTATIONSORWARRANTIESWITHRESPECTTOTHEACCURACYORCOMPLETE- NESSOFTHECONTENTSOFTHISWORKANDSPECIFICALLYDISCLAIMALLWARRANTIES, INCLUDINGWITHOUTLIMITATIONWARRANTIESOFFITNESSFORAPARTICULARPURPOSE. NOWARRANTYMAYBECREATEDOREXTENDEDBYSALESORPROMOTIONALMATERIALS. THEADVICEANDSTRATEGIESCONTAINEDHEREINMAYNOTBESUITABLEFOREVERYSIT- UATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONALASSISTANCEISREQUIRED,THESERVICESOFACOMPETENTPROFESSIONAL PERSONSHOULDBESOUGHT.NEITHERTHEPUBLISHERNORTHEAUTHORSHALLBELIABLE FORDAMAGESARISINGHEREFROM.THEFACTTHATANORGANIZATIONORWEBSITEIS REFERREDTOINTHISWORKASACITATIONAND/ORAPOTENTIALSOURCEOFFURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATIONTHEORGANIZATIONORWEBSITEMAYPROVIDEORRECOMMENDATIONSIT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEB SITES LISTED INTHISWORKMAYHAVECHANGEDORDISAPPEAREDBETWEENWHENTHISWORKWAS WRITTENANDWHENITISREAD. Forgeneralinformationonourotherproductsandservicesortoobtaintechnicalsupport,please contactourCustomerCareDepartmentwithintheU.S.at(800)762-2974,outsidetheU.S.at(317) 572-3993orfax(317)572-4002. Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsinprintmay notbeavailableinelectronicbooks. LibraryofCongressCataloging-in-PublicationData:AvailablefromPublisher Trademarks:Wiley,theWileylogo,andrelatedtradedressaretrademarksorregisteredtrademarksof JohnWiley&Sons,Inc.and/oritsaffiliates,intheUnitedStatesandothercountries,andmaynotbe usedwithoutwrittenpermission.Allothertrademarksarethepropertyoftheirrespectiveowners. WileyPublishing,Inc.,isnotassociatedwithanyproductorvendormentionedinthisbook. isatrademarkofWileyPublishing,Inc. ii P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 About the Authors BryanPfaffenbergeristheauthorofmorethan75booksoncomputersandthe Internet,includingthebest-sellingDiscovertheInternet,fromIDGBooksWorldwide. Heteachesadvancedprofessionalcommunicationandthesociologyofcomputingin theUniversityofVirginia’sDivisionofTechnology,Culture,andCommunication. BryanlivesinCharlottesville,Virginia,withhisfamilyandanextremelyspoiledcat. StevenM.Schaferisaveteranoftechnologyandpublishing.Heprogramsinseveral languages,workswithavarietyoftechnologies,andhasbeenpublishedinseveral technicalpublicationsandarticles.HecurrentlyistheCOO/CTOforProgeny,an opensource–basedserviceandsupportcompany.Stevecanbereachedbye-mailat [email protected]. ChuckWhiteisaWebdevelopmentprofessionalwhohaswrittennumerousarticles andbooksonWebdevelopment,includingMasteringXSLTandDevelopingKillerWeb AppswithDreamweaverMXandC#,andtutorialsforIBMDeveloperWorks.Hisfirst publishedworkonCSSwasforWebTechniquesmagazinein1997,andhehasbeen workingwithlargeandsmallWebsitessince1996.HeiscurrentlyaWebsoftware engineerforeBay. BillKarow,inadditiontowritingseveralcomputerbooks,hasservedasa contributorortechnicaleditoronmorethan30otherbooks.Formerlyinchargeof systemsdevelopmentforWaltDisneyEntertainment,Billnowservesasacomputer consultantintheOrlandoareawhenhe’snotoutridinghisbicycle.Healsohasthe distinctionofhavingstoodatopmanyofthebuildingsatWaltDisneyWorld,fanfare trumpetinhand(withtheirpermission,ofcourse). iii P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 Credits AcquisitionsEditor VicePresident&Executive JimMinatel GroupPublisher RichardSwadley DevelopmentEditor MarciaEllett VicePresidentandExecutive Publisher ProductionEditor BobIpsen GabrielleNabi VicePresidentandPublisher TechnicalEditor JosephB.Wikert Wiley-DreamtechIndiaPvtLtd ExecutiveEditorialDirector CopyEditor MaryBednarek TechBooks ProjectCoordinator EditorialManager ErinSmith MaryBethWakefield ProofreadingandIndexing TechBooksProductionServices iv P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 ToMiri,I’lldesperatelymiss mylate-nightcompany. Steve v P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 Acknowledgments ............................................... A booksuchasthisishardwork,andonlyasmallportionofthatworkis performedbytheauthors.Assuch,theauthorswouldliketothank thefollowing: ThemanagementteamatWileyPublishingforcontinuingtosupportlarge,tutorial- referencebookssofolkslikeyou(thereader)canbenefit. JimMinatel,forputtingtogethertheplan,assemblingtheteam,andmakingusall behave. BryanPfaffenberger,theoriginalauthorofthe1stand2ndEditionsofthisbook,for providingasolidoutlineandorganizationforustofollow. JohnDaily,whocompiledthereferentialinformationinAppendixesAandB,for steppingupandprovidingthecriticalattentiontodetailnecessaryforsuchwork. MarciaEllett,forcontinuingtobeoneofthebestdevelopmenteditorsaround— keepingusallontrackandorganized—andforprovidingcrucialinsightsand feedbackthroughouttheprocess. Wiley-DreamtechIndiaPvtLtd.forprovidingthetechnicalediting—ensuringthatthe informationisaccurateandpertinent,aswellasprovidingadditionalusefulinsights. TechBooks,forensuringthatourtextiseasytoreadandunderstand,despiteour bestefforts. Theproductioncrewwhopackagedtherawmaterialintothisnicepackageyou nowhold. Andlast,butdefinitelynotleast,ourfriendsandfamilywhogiveustheloveand supportthatenablesustodothisinthefirstplace. vi P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 Contents at a Glance ............................................... Acknowledgments.................................................................iv Introduction....................................................................xxiii Part I: Understanding (X)HTML.....................................1 Chapter1: IntroducingtheWebandHTML.............................................3 Chapter2: WhatGoesIntoaWebPage?...............................................19 Chapter3: StartingYourWebPage....................................................43 Part II: HTML/XHTML Authoring Fundamentals..................53 Chapter4: Lines,LineBreaks,andParagraphs........................................55 Chapter5: Lists.......................................................................75 Chapter6: Images.....................................................................91 Chapter7: Links.....................................................................113 Chapter8: Text......................................................................127 Chapter9: SpecialCharacters........................................................135 Chapter10: Tables...................................................................149 Chapter11: PageLayoutwithTables.................................................173 Chapter12: Frames..................................................................189 Chapter13: Forms...................................................................205 Chapter14: Multimedia..............................................................227 Chapter15: Scripts...................................................................257 Part III: Controlling Presentation with CSS......................267 Chapter16: IntroducingCascadingStyleSheets......................................269 Chapter17: CreatingStyleRules.....................................................279 Chapter18: Fonts....................................................................297 Chapter19: TextFormatting.........................................................313 Chapter20: Padding,Margins,andBorders..........................................337 Chapter21: ColorsandBackgrounds................................................347 Chapter22: Tables...................................................................359 Chapter23: ElementPositioning.....................................................369 Chapter24: DefiningPagesforPrinting..............................................387 Part IV: Advanced Web Authoring...............................399 Chapter25: JavaScript...............................................................401 Chapter26: DynamicDHTML........................................................429 vii P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 viii ContentsataGlance Chapter27: DynamicHTMLwithCSS................................................449 Chapter28: IntroductiontoServer-SideScripting....................................469 Chapter29: IntroductiontoDatabase-DrivenWebPublishing........................479 Chapter30: CreatingaWeblog.......................................................495 Chapter31: IntroductiontoXML.....................................................505 Chapter32: XMLProcessingandImplementations...................................523 Part V: Testing, Publishing, and Maintaining Your Site..........547 Chapter33: TestingandValidatingYourDocuments.................................549 Chapter34: WebDevelopmentSoftware.............................................555 Chapter35: ChoosingaServiceProvider.............................................567 Chapter36: UploadingYourSitewithFTP............................................575 Chapter37: PublicizingYourSiteandBuildingYourAudience.......................583 Chapter38: MaintainingYourSite....................................................591 Part VI: Principles of Professional Web Design and Development.......................................601 Chapter39: TheWebDevelopmentProcess..........................................603 Chapter40: DevelopingandStructuringContent.....................................617 Chapter41: DesigningforUsabilityandAccessibility................................629 Chapter42: DesigningforanInternationalAudience.................................645 Chapter43: Security.................................................................659 Chapter44: Privacy..................................................................667 Part VII: Appendixes.............................................677 AppendixA:HTML4.01Elements................................................679 AppendixB:CSSProperties......................................................743 Index............................................................................773 P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 Contents ............................................... Acknowledgments .................................................. iv Introduction.......................................................xxiii Part I: Understanding (X)HTML 1 Chapter 1: Introducing the Web and HTML...............................3 WhatIstheWorldWideWeb?...............................................................3 HowDoestheWebWork?...................................................................3 WhatIsHypertext?.........................................................................4 WhereDoesHTMLFitIn?...................................................................5 TheinventionofHTML...............................................................5 AshorthistoryofHTML.............................................................6 Sowhomakestherules?.............................................................8 WhatIsCSS?...............................................................................10 Themaintenancenightmare........................................................10 EnterCSS...........................................................................13 Whatdoes“cascading”mean?......................................................14 WhatIsXHTML?...........................................................................15 CreatinganHTMLDocument..............................................................15 WritingHTML.......................................................................16 NameyourfileswithaWeb-friendlyextension......................................16 Formatyourtext....................................................................16 Structureyourdocument...........................................................16 Don’tINeedaWebServer?................................................................17 Summary..................................................................................18 Chapter 2: What Goes Into a Web Page?................................19 SpecifyingDocumentType................................................................19 TheOverallStructure:HTML,Head,andBody............................................20 The<html>tag......................................................................20 The<head>tag......................................................................20 Styles......................................................................................22 BlockElements:MarkupforParagraphs...................................................24 Formattedparagraphs..............................................................25 Headings............................................................................26 Quotedtext.........................................................................27 Listelements........................................................................28 Preformattedtext...................................................................30 Divisions............................................................................30 InlineElements:MarkupforCharacters...................................................31 Basicinlinetags.....................................................................31 Spanning............................................................................32 SpecialCharacters(Entities)..............................................................32 ix P1:FMK WY022-FM WY022/Pfaffenberger WY022/Pfaffenberger-v3.cls June15,2004 23:23 x Contents OrganizationalElements...................................................................33 Tables...............................................................................34 Forms...............................................................................36 LinkingtoOtherPages....................................................................37 Images.....................................................................................38 Comments.................................................................................39 Scripts.....................................................................................40 PuttingitAllTogether.....................................................................40 Summary..................................................................................41 Chapter 3: Starting Your Web Page......................................43 BasicRulesforHTMLCode................................................................43 Useliberalwhitespace.............................................................43 Usewell-formedHTML..............................................................44 Commentyourcode................................................................45 CreatingtheBasicStructure...............................................................46 DeclaringtheDocumentType.............................................................46 SpecifyingtheDocumentTitle.............................................................47 ProvidingInformationtoSearchEngines..................................................48 SettingtheDefaultPath...................................................................49 CreatingAutomaticRefreshesandRedirects..............................................49 PageBackgroundColorandBackgroundImages..........................................50 Specifyingthedocumentbackgroundcolor.........................................50 Specifyingthedocumentbackgroundimage........................................51 Summary..................................................................................52 Part II: HTML/XHTML Authoring Fundamentals 53 Chapter 4: Lines, Line Breaks, and Paragraphs..........................55 LineBreaks................................................................................55 Paragraphs..........................................................................56 Manuallinebreaks..................................................................59 NonbreakingSpaces.......................................................................60 SoftHyphens..............................................................................61 PreservingFormatting—The<pre>Element...............................................63 Indents....................................................................................64 Headings..................................................................................66 HorizontalRules...........................................................................68 Groupingwiththe<div>Element..........................................................70 Summary..................................................................................73 Chapter 5: Lists..........................................................75 UnderstandingLists.......................................................................75 Ordered(Numbered)Lists................................................................76 Unordered(Bulleted)Lists................................................................82 DefinitionLists............................................................................86 NestedLists...............................................................................87 Summary..................................................................................89 Chapter 6: Images.......................................................91 ImageFormatsfortheWeb................................................................91 Imagecompression.................................................................91 Compressionoptions...............................................................91 Imagecolordepth...................................................................93 Enhancingdownloadingspeed......................................................94