Tải bản đầy đủ (.pdf) (1,241 trang)

OReilly HTML and XHTML the definitive guide 5th edition aug 2002 ISBN 059600382x

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




Tableof

Contents
• Index
• Reviews
• Examples
Reader

Reviews
• Errata

HTML&XHTML:TheDefinitiveGuide,
5thEdition
ByBillKennedy,ChuckMusciano

Publisher :O'Reilly
PubDate :August2002
ISBN :0-596-00382-X
Pages :670
Slots :1
HTML&XHTML:TheDefinitiveGuide,5thEditionisthe
mostcomprehensive,up-to-datebookavailableonHTML
andXHTML.Theauthorscovereveryelementof
HTML/XHTMLindetail,explaininghoweachelement
worksandhowitinteractswithotherelements.With
hundredsofexamples,thebookgivesyoumodelsfor
writingyourowneffectivewebpagesandformastering
advancedfeatureslikestylesheetsandframes.








HTML&XHTML:TheDefinitiveGuide,
5thEdition

ByBillKennedy,ChuckMusciano
Tableof

Contents Publisher :O'Reilly
PubDate :August2002
• Index
ISBN :0-596-00382-X
• Reviews
Pages :670
Slots :1
• Examples
Reader

Reviews
• Errata



Copyright




Dedication



Preface



OurAudience



TextConventions



VersionsandSemantics



HTMLVersusXHTML



CommentsandQuestions



Acknowledgments





Chapter1.HTML,XHTML,andtheWorldWideWeb



Section1.1.TheInternet



Section1.2.TalkingtheInternetTalk



Section1.3.HTMLandXHTML:WhatTheyAre



Section1.4.HTMLandXHTML:WhatTheyAren't



Section1.5.StandardsandExtensions



Section1.6.ToolsfortheWebDesigner





Chapter2.QuickStart



Section2.1.WritingTools



Section2.2.AFirstHTMLDocument



Section2.3.EmbeddedTags



Section2.4.HTMLSkeleton



Section2.5.TheFleshonanHTMLorXHTMLDocument







Section2.6.Text



Section2.7.Hyperlinks



Section2.8.ImagesAreSpecial



Section2.9.Lists,SearchableDocuments,andForms



Section2.10.Tables



Section2.11.Frames



Section2.12.StyleSheetsandJavaScript



Section2.13.ForgingAhead





Chapter3.AnatomyofanHTMLDocument



Section3.1.AppearancesCanDeceive



Section3.2.StructureofanHTMLDocument



Section3.3.TagsandAttributes



Section3.4.Well-FormedDocumentsandXHTML



Section3.5.DocumentContent



Section3.6.HTML/XHTMLDocumentElements




Section3.7.TheDocumentHeader



Section3.8.TheDocumentBody



Section3.9.EditorialMarkup



Section3.10.The<bdo>Tag




Chapter4.TextBasics



Section4.1.DivisionsandParagraphs



Section4.2.Headings




Section4.3.ChangingTextAppearanceandMeaning



Section4.4.Content-BasedStyleTags



Section4.5.PhysicalStyleTags



Section4.6.PreciseSpacingandLayout



Section4.7.BlockQuotes



Section4.8.Addresses



Section4.9.SpecialCharacterEncoding



Section4.10.HTML'sObsoleteExpandedFontHandling





Chapter5.Rules,Images,andMultimedia



Section5.1.HorizontalRules



Section5.2.InsertingImagesinYourDocuments



Section5.3.DocumentColorsandBackgroundImages



Section5.4.BackgroundAudio



Section5.5.AnimatedText



Section5.6.OtherMultimediaContent





Chapter6.LinksandWebs



Section6.1.HypertextBasics



Section6.2.ReferencingDocuments:TheURL



Section6.3.CreatingHyperlinks




Section6.4.CreatingEffectiveLinks



Section6.5.Mouse-SensitiveImages



Section6.6.CreatingSearchableDocuments




Section6.7.Relationships



Section6.8.SupportingDocumentAutomation




Chapter7.FormattedLists



Section7.1.UnorderedLists



Section7.2.OrderedLists



Section7.3.The<li>Tag



Section7.4.NestingLists




Section7.5.DefinitionLists



Section7.6.AppropriateListUsage



Section7.7.DirectoryLists



Section7.8.MenuLists




Chapter8.CascadingStyleSheets



Section8.1.TheElementsofStyles



Section8.2.StyleSyntax



Section8.3.StyleClasses




Section8.4.StyleProperties



Section8.5.TaglessStyles:The<span>Tag



Section8.6.ApplyingStylestoDocuments




Chapter9.Forms



Section9.1.FormFundamentals



Section9.2.The<form>Tag



Section9.3.ASimpleFormExample




Section9.4.UsingEmailtoCollectFormData



Section9.5.The<input>Tag



Section9.6.The<button>Tag



Section9.7.MultilineTextAreas



Section9.8.MultipleChoiceElements



Section9.9.GeneralForm-ControlAttributes



Section9.10.LabelingandGroupingFormElements




Section9.11.CreatingEffectiveForms



Section9.12.FormsProgramming




Chapter10.Tables



Section10.1.TheStandardTableModel



Section10.2.BasicTableTags



Section10.3.AdvancedTableTags



Section10.4.BeyondOrdinaryTables





Chapter11.Frames




Section11.1.AnOverviewofFrames



Section11.2.FrameTags



Section11.3.FrameLayout



Section11.4.FrameContents



Section11.5.The<noframes>Tag



Section11.6.InlineFrames



Section11.7.NamedFrameorWindowTargets





Chapter12.ExecutableContent



Section12.1.AppletsandObjects



Section12.2.EmbeddedContent



Section12.3.JavaScript



Section12.4.JavaScriptStyleSheets(Antiquated)




Chapter13.DynamicDocuments



Section13.1.AnOverviewofDynamicDocuments




Section13.2.Client-PullDocuments



Section13.3.Server-PushDocuments




Chapter14.NetscapeLayoutExtensions



Section14.1.CreatingWhitespace



Section14.2.MulticolumnLayout



Section14.3.Layers




Chapter15.XML




Section15.1.LanguagesandMetalanguages



Section15.2.DocumentsandDTDs



Section15.3.UnderstandingXMLDTDs



Section15.4.ElementGrammar



Section15.5.ElementAttributes



Section15.6.ConditionalSections



Section15.7.BuildinganXMLDTD




Section15.8.UsingXML




Chapter16.XHTML



Section16.1.WhyXHTML?



Section16.2.CreatingXHTMLDocuments



Section16.3.HTMLVersusXHTML



Section16.4.XHTML1.1



Section16.5.ShouldYouUseXHTML?





Chapter17.Tips,Tricks,andHacks



Section17.1.TopoftheTips



Section17.2.CleaningUpAfterYourHTMLEditor



Section17.3.TrickswithTables




Section17.4.TransparentImages



Section17.5.TrickswithWindowsandFrames




AppendixA.HTMLGrammar




SectionA.1.GrammaticalConventions



SectionA.2.TheGrammar




AppendixB.HTML/XHTMLTagQuickReference



SectionB.1.CoreAttributes



SectionB.2.HTMLQuickReference




AppendixC.CascadingStyleSheetPropertiesQuickReference



AppendixD.TheHTML4.01DTD




AppendixE.TheXHTML1.0DTD



AppendixF.CharacterEntities



AppendixG.ColorNamesandValues



SectionG.1.ColorValues



SectionG.2.ColorNames



SectionG.3.TheStandardColorMap




Colophon




Index


Copyright©2002,2000,1998,1997,1996O'Reilly&Associates,Inc.All
rightsreserved.
PrintedintheUnitedStatesofAmerica.
PublishedbyO'Reilly&Associates,Inc.,1005GravensteinHighway
North,Sebastopol,CA95472.
O'Reilly&Associatesbooksmaybepurchasedforeducational,
business,orsalespromotionaluse.Onlineeditionsarealsoavailablefor
mosttitles().Formoreinformationcontactour
corporate/institutionalsalesdepartment:800-998-9938or

NutshellHandbook,theNutshellHandbooklogo,andtheO'Reillylogo
areregisteredtrademarksofO'Reilly&Associates,Inc.Manyofthe
designationsusedbymanufacturersandsellerstodistinguishtheir
productsareclaimedastrademarks.Wherethosedesignationsappearin
thisbook,andO'Reilly&Associates,Inc.wasawareofatrademark
claim,thedesignationshavebeenprintedincapsorinitialcaps.The
associationbetweentheimageofakoalaandthetopicofHTMLand
XHTMLisatrademarkofO'Reilly&Associates,Inc.
Whileeveryprecautionhasbeentakeninthepreparationofthisbook,
thepublisherandtheauthorassumenoresponsibilityforerrorsor
omissions,orfordamagesresultingfromtheuseoftheinformation
containedherein.


Dedication
Thisbookisdedicatedtoourwivesandchildren,Cindy,Courtney,
andCole,andJeanne,Eva,andEthan.Withouttheirloveand

patience,weneverwouldhavehadthetimeorstrengthtowrite.


Preface
LearningHypertextMarkupLanguage(HTML)andExtensibleHypertext
MarkupLanguage(XHTML)islikelearninganynewlanguage,computer
orhuman.Moststudentsfirstimmersethemselvesinexamples.Studying
othersisanaturalwaytolearn,makinglearningeasyandfun.Our
advicetoanyonewantingtolearnHTMLandXHTMListogetoutthere
ontheWebwithasuitablebrowserandseeforyourselfwhatlooksgood,
what'seffective,andwhatworksforyou.Examineothers'documentsand
ponderthepossibilities.Mimicryishowmanyofthecurrentwebmasters
havelearnedthelanguage.
Imitationcantakeyouonlysofar,though.Examplescanbebothgood
andbad.Learningbyexamplehelpsyoutalkthetalk,butnotwalkthe
walk.Tobecometrulyconversant,youmustlearnhowtousethe
languageappropriatelyinmanydifferentsituations.Youcouldlearnall
thatbyexample,ifyoulivelongenough.
Remember,too,thatcomputer-basedlanguagesaremoreexplicitthan
humanlanguages.Youhavetogetthelanguagesyntaxcorrectoritwon't
work.Thenthereistheproblemof"standards."Committeesof
academicsandindustryexpertsdefinethepropersyntaxandusageofa
computerlanguagelikeHTML.Theproblemisthatbrowser
manufacturerslikeNetscapeCommunicationsCorporation(anAmerica
Onlinecompany)andMicrosoftCorporationchoosewhichpartsofthe
standardtheywilluseandwhichpartstheywillignore.Theyevenmake
uptheirownparts,whichmayeventuallybecomestandards.
Standardschange,too.HTMLisundergoingaconversionintoXHTML,
makingitanapplicationoftheExtensibleMarkupLanguage(XML).
HTMLandXHTMLaresosimilarthatweoftenrefertothemasasingle

language,buttherearekeydifferences,whichwediscusslaterinthis
Preface.
Tobesafe,thewaytobecomefluentinHTMLandXHTMListhrougha
comprehensive,up-to-datelanguagereferencethatcoversthelanguage


syntax,semantics,andvariationsindetailtohelpyoudistinguish
betweengoodandbadusage.
There'sonemorestepleadingtofluencyinalanguage.Tobecomea
truemasterofthelanguage,youneedtodevelopyourownstyle.That
meansknowingnotonlywhatisappropriate,butwhatiseffective.Layout
matters.Alot.Sodoestheorderofpresentationwithinadocument,
betweendocuments,andbetweendocumentcollections.
OurgoalinwritingthisbookistohelpyoubecomefluentinHTMLand
XHTML,fullyversedintheirsyntax,semantics,andelementsofstyle.
Wetakethenaturallearningapproach,usingexamples(goodones,of
course).Wecoverindetaileveryelementofthecurrentlyaccepted
standardversionsofthelanguages(HTML4.01andXHTML1.0)aswell
asallofthecurrentextensionssupportedbythepopularbrowsers,
explaininghoweachelementworksandhowitinteractswithallofthe
otherelements.
And,withallduerespecttoStrunkandWhite,throughoutthebookwe
giveyousuggestionsforstyleandcompositiontohelpyoudecidehow
besttouseHTMLandXHTMLtoaccomplishavarietyoftasks,from
simpleonlinedocumentationtocomplexmarketingandsales
presentations.Weshowyouwhatworksandwhatdoesn't,whatmakes
sensetothosewhoviewyourpages,andwhatmightbeconfusing.
Inshort,thisbookisacompleteguidetocreatingdocumentsusing
HTMLandXHTML,startingwithbasicsyntaxandsemantics,and
finishingwithbroadstyleguidelinestohelpyoucreatebeautiful,

informative,accessibledocumentsthatyou'llbeproudtodelivertoyour
readers.


OurAudience
Wewrotethisbookforanyoneinterestedinlearningandusingthe
languageoftheWeb,fromthemostcasualusertothefull-timedesign
professional.Wedon'texpectyoutohaveanyexperienceinHTMLor
XHTMLbeforepickingupthisbook.Infact,wedon'tevenexpectthat
you'veeverbrowsedtheWeb,althoughwe'dbeverysurprisedifyou
haven't.BeingconnectedtotheInternetisnotstrictlynecessarytouse
thisbook,butifyou'renotconnected,thisbookbecomeslikeatravel
guideforthehomebound.
Theonlythingsweaskyoutohaveareacomputer,atexteditorthatcan
createsimpleASCIItextfiles,andcopiesofthelatestleadingweb
browsers--preferablyNetscapeNavigatorandInternetExplorer.
BecauseHTMLandXHTMLdocumentsarestoredinauniversally
acceptedformat--ASCIItext--andbecausethelanguagesare
completelyindependentofanyspecificcomputer,wewon'tevenmake
anassumptionaboutthekindofcomputeryou'reusing.However,
browsersdovarybyplatformandoperatingsystem,whichmeansthat
yourHTMLorXHTMLdocumentscanlookquitedifferentdependingon
thecomputerandbrowserversion.Weexplainhowthevariousbrowsers
usecertainlanguagefeatures,payingparticularattentiontohowtheyare
different.
IfyouarenewtoHTML,theWeb,orhypertextdocumentationingeneral,
youshouldstartbyreadingChapter1.Init,wedescribehowallthese
technologiescometogethertocreatewebsofinterrelateddocuments.
IfyouarealreadyfamiliarwiththeWeb,butnotwithHTMLorXHTML
specifically,startbyreadingChapter2.Thischapterisabriefoverviewof

themostimportantfeaturesofthelanguageandservesasaroadmapto
howweapproachthelanguageintheremainderofthebook.
Subsequentchaptersdealwithspecificlanguagefeaturesinaroughly
top-downapproachtoHTMLandXHTML.Readtheminorderfora
completetourthroughthelanguage,orjumparoundtofindtheexact


featureyou'reinterestedin.


TextConventions
Throughoutthebook,weuseaconstant-widthtypefacetohighlight
anyliteralelementoftheHTML/XHTMLstandards,tags,andattributes.
Wealwaysuselowercaselettersfortags.[1]Weuseitalicforfilenames
andURLsandtoindicatenewconceptswhentheyaredefined.Elements
youneedtosupplywhencreatingyourowndocuments,suchastag
attributesoruser-definedstrings,appearinconstant-widthitalic
inthecode.
[1]HTMLiscase-insensitivewithregardtotagandattributenames,butXHTMLiscasesensitive.AndsomeHTMLitems,suchassourcefilenames,arecase-sensitive,sobe
careful.

Wediscusselementsofthelanguagethroughoutthebook,butyou'llfind
eachonecoveredindepth(somemightsayinnauseatingdetail)ina
shorthand,quick-referencedefinitionboxthatlooksliketheonethat
follows.Thefirstlineoftheboxcontainstheelementname,followedbya
briefdescriptionofitsfunction.Next,welistthevariousattributes,ifany,
oftheelement:thosethingsthatyoumayormustspecifyaspartofthe
element.



<title>
Function
Definesthedocumenttitle
Attributes
dirlang
Endtag
</title>;neveromitted
Contains
plain_text
Usedin
head_content

Weusethefollowingsymbolstoidentifytagsandattributesthatarenot
intheHTML4.01orXHTML1.0standardsbutareadditionstothe
languages:
Netscapeextensiontothestandards
InternetExplorerextensiontothestandards
Thedescriptionalsoincludestheendingtag,ifany,fortheelement,
alongwithageneralindicationofwhethertheendtagmaybesafely
omittedingeneraluseinHTML.Forthefewtagsthatrequireendtagsin
XHTMLbutdonothavetheminHTML,thelanguageletsyouindicate
thatbyplacingaforwardslash(/)beforethetag'sclosingbracket,asin

.Inthesecases,thetagmayalsocontainattributes,indicated
withaninterveningellipsis,suchas.
The"Contains"headernamestheruleintheHTMLgrammarthatdefines


theelementstobeplacedwithinthistag.Similarly,the"Usedin"header
liststhoserulesthatallowthistagaspartoftheircontent.Theserules
aredefinedinAppendixA.

Finally,HTMLandXHTMLarefairlyintertwinedlanguages.Youwill
occasionallyuseelementsindifferentwaysdependingoncontext,and
manyelementsshareidenticalattributes.Whereverpossible,weplacea
cross-referenceinthetextthatleadsyoutoarelateddiscussion
elsewhereinthebook.Thesecross-references,liketheoneattheendof
thisparagraph,serveasacrudepapermodelofhypertext
documentation,onethatwouldbereplacedwithatruehypertextlink
shouldthisbookbedeliveredinanelectronicformat.[Section3.3.1]
Weencourageyoutofollowthesereferenceswheneverpossible.Often,
wecoveranattributebrieflyandexpectyoutojumptothecrossreferenceforamoredetaileddiscussion.Inothercases,followingthelink
takesyoutoalternativeusesoftheelementunderdiscussionortostyle
andusagesuggestionsthatrelatetothecurrentelement.


VersionsandSemantics
ThelatestHTMLstandardisVersion4.01,butmostupdatesand
changestothelanguagestandardweremadeinVersion4.0.Therefore,
throughoutthebook,wegenerallyrefertotheHTMLstandardasHTML
4,encompassingVersions4.0andlater.Weexplicitlystatethe"dot"
versionnumberonlywhenitisrelevant.
TheXHTMLstandardiscurrentlyinitsfirstiteration,1.0.Asecond
version(XHTML1.1)hasbeenproposedbutnotyetestablished.Forthe
mostpart,XHTML1.0isidenticaltoHTML4.01;wedetailtheir
differencesinChapter16.Throughoutthebook,wespecificallynote
caseswhereXHTMLhandlesafeatureorelementdifferentlythanthe
originallanguage,HTML.
TheHTMLandXHTMLstandardsmakeveryclearthedistinction
between"elementtypes"ofadocumentandthemarkup"tags"that
delimitthoseelements.Forexample,thestandardreferstothe
paragraphelementtype,whichisnotthesameasthe

tag.The


paragraphelementconsistsoftheacceptedelement-typenamewithin
thestartingtag(

),interveningcontent,andtheendingparagraphtag
(

).The

tagisthestartingtagfortheparagraphelement,andits
contents,knownasattributes,ultimatelyaffecttheparagraphelement
type'scontents.
Althoughtheseareimportantdistinctions,we'repragmatists.Itisthe
markuptagthatauthorsapplyintheirdocumentsandthataffectsany
interveningcontent.Accordingly,throughoutthebook,werelaxthe
distinctionbetweenelementtypesandtags,oftentalkingabouttagsand
allrelatedcontentsandnotnecessarilyusingtheterm"element-type"
whenitwouldbetechnicallyappropriatetomakethedistinction.Forgive
usthetransgression,butwedosoforthesakeofclarity.


HTMLVersusXHTML
It'snotLatin,butHTMLhasreachedmiddleageinstandardVersion
4.01.TheW3Chasnoplanstodevelopanotherversionandhasofficially
saidso.Rather,HTMLisbeingsubsumedandmodularizedasan
ExtensibleMarkupLanguage(XML).ItsnewnameisXHTML,Extensible
HypertextMarkupLanguage.
TheemergenceofXHTMLisjustanotherchapterintheoftentumultuous
historyofHTMLandtheWeb,whereconfusionforauthorsisthenorm,
nottheexception.Attheworstpoint,theeldersoftheWorldWideWeb
Consortium(W3C)responsibleforacceptedandacceptableusesofthe
language--i.e.,standards--lostcontrolofthelanguageinthebrowser
"wars"betweenNetscapeandMicrosoft.TheabortiveHTML+standard
nevergotofftheground,andHTML3.0becamesoboggeddownin
debatethattheW3Csimplyshelvedtheentiredraftstandard.HTML3.0
neverhappened,despitewhatsomeopportunisticmarketersclaimedin
theirliterature.Instead,bylate1996,thebrowsermanufacturers


convincedtheW3CtoreleaseHTMLstandardVersion3.2,whichforall
intentsandpurposessimplystandardizedmostofNetscape'sHTML
extensions.
Netscape'sdominanceastheleadingbrowser,aswellasaleaderin
Webtechnologies,fadedbytheendofthemillennium.Bythen,Microsoft
hadeffectivelybundledInternetExplorerintotheWindowsoperating
system,notonlyasaninstalledapplication,butalsoasadominant
featureoftheGUIdesktop.And,too,InternetExplorerintroducedseveral
features(albeitnonstandardatthetime)thatappealedprincipallytothe
growingInternetbusinessandmarketingcommunity.
Fortunatelyforthoseofuswhoappreciateandstronglysupport
standards,theW3CtookbackitsprimacyrolewithHTML4.0,which
standstodayasHTMLVersion4.01,releasedinDecember1999.
AbsorbingmanyoftheNetscapeandInternetExplorerinnovations,the
standardisclearerandcleanerthananypreviousones,establishessolid
implementationmodelsforconsistencyacrossbrowsersandplatforms,


providesstrongsupportandincentivesforthecompanionCascading
StyleSheets(CSS)standardforHTML-baseddisplays,andmakes
provisionsforalternative(nonvisual)useragents,aswellasformore
universallanguagesupports.
Cleanerandcleareraside,theW3CrealizedthatHTMLcouldneverkeep
upwiththedemandsofthewebcommunityformorewaystodistribute,
process,anddisplaydocuments.HTMLoffersonlyalimitedsetof
document-creationprimitivesandishopelesslyincapableofhandling
nontraditionalcontentlikechemicalformulae,musicalnotation,or
mathematicalexpressions.Norcanitwellsupportalternativedisplay
media,suchashandheldcomputersorintelligentcellularphones.
Toaddressthesedemands,theW3CdevelopedtheXMLstandard.XML

providesawaytocreatenew,standards-basedmarkuplanguagesthat
don'ttakeanactoftheW3Ctoimplement.XML-compliantlanguages
deliverinformationthatcanbeparsed,processed,displayed,sliced,and
dicedbythemanydifferentcommunicationtechnologiesthathave
emergedsincetheWebsparkedthedigitalcommunicationrevolutiona
decadeago.XHTMLisHTMLreformulatedtoadheretotheXML
standard.ItisthefoundationlanguageforthefutureoftheWeb.
WhynotjustdropHTMLforXHTML?Formanyreasons.Firstand
foremost,XHTMLhasnotexactlytakentheWebbystorm.There'sjust
toomuchcurrentinvestmentinHTML-baseddocumentationand
expertiseforthattohappenanytimesoon.Besides,XHTMLisHTML
4.01reformulatedasanapplicationofXML.KnowHTML4andyou'reall
readyforthefuture.[2]
[2]WeplumbthedepthsofXMLandXHTMLinChapter15andChapter16.

DeprecatedFeatures
Oneoftheunpopularthingsstandards-bearershavetodoismake
choicesbetweenpopularandproper.TheauthorsoftheHTMLand
XHTMLstandardsexercisethatresponsibilityby"deprecating"those
featuresofthelanguagethatinterfereinthegrandschemeofthings.


Forinstance,the
tagtellsthebrowsertodisplaytheenclosed
textcenteredinthedisplaywindow.ButtheCSSstandardprovidesways
tocentertext,too.TheW3CchoosestosupporttheCSSwayand
discouragestheuseof
bydeprecatingthetag.Theplanis,in
somelaterstandardversion,tostopusing
andother
deprecatedelementsandattributesofthelanguage.
Throughoutthebook,wespeciallynoteandcontinuouslyremindyou
whenanHTMLtagorothercomponentisdeprecatedinthecurrent

standards.Shouldyoustopusingthemnow?Yesandno.
Yes,becausethereisapreferredandperhapsbetterwaytoaccomplish
thesamething.Byexercisingthatalternative,youensurethatyour
documentswillsurviveformanyyearstocomeontheWeb.And,yes,
becausethetoolsyoumayusetoprepareHTML/XHTMLdocuments
probablyadheretothepreferredstandard.Youmaynothaveachoice,
unlessyoudisableyourtools.Inanyevent,unlessyouhand-composeall
yourdocuments,you'llneedtoknowhowthepreferredwayworkssothat
youcanidentifythecodeandmodifyit.
Howevercompellingthereasonsfornotusingdeprecatedelementsand
attributesare,theystillarepartofthestandards.Theyremainwell
supportedbymostbrowsersandaren'texpectedtodisappearanytime
soon.Infact,sincethereisnoplantochangetheHTMLstandard,the
"deprecated"stampisverymisleading.
So,no,youdon'thavetoworryaboutdeprecatedHTMLfeatures.There
isnoreasontopanic,certainly.Weencourageyoutouseandcontinueto
usethem,sincethedeprecatedfeaturestypicallyaresimplerand
eminentlymorehuman-readablethantheiralternatives.

ADefinitiveGuide
TheparadoxinallthisisthateventheHTML4.01standardisnotthe
definitiveresource.TherearemanymorefeaturesofHTMLinpopular
useandsupportedbythepopularbrowsersthanareincludedinthe
latestlanguagestandard.Andtherearemanypartsofthestandardsthat


areignored.Wepromiseyou,thingscangetdownrightconfusing.
We'vemanagedtosortthingsoutforyou,though,soyoudon'thaveto
sweatoverwhatworksanddoesn'tworkwithwhatbrowser.Thisbook,
therefore,isthedefinitiveguidetoHTMLandXHTML.Wegivedetailsfor

alltheelementsoftheHTML4.01andXHTML1.0standards,plusthe
varietyofinterestingandusefulextensionstothelanguage--some
proposedstandards--thatthepopularbrowsermanufacturershave
chosentoincludeintheirproducts,suchas:
CascadingStyleSheets
JavaandJavaScript
Layers
Multiplecolumns
Andwhilewetellyouabouteachandeveryfeatureofthelanguage,
standardornot,wealsotellyouwhichbrowsersordifferentversionsof
thesamebrowserimplementaparticularextensionandwhichdon't.
That'scriticalknowledgewhenyouwanttocreatewebpagesthattake
advantageofthelatestversionofNetscapeversuspagesthatare
accessibletothelargernumberofpeopleusingInternetExploreroreven
Lynx,aonce-populartext-onlybrowserforUnixsystems.
Inaddition,thereareafewthingsthatarecloselyrelatedbutnotdirectly
partofHTML.Forexample,wetouch,butdonothandle,JavaScript,
CGI,andJavaprogramming.TheyallworkcloselywithHTML
documentsandrunwithoralongsidebrowsers,buttheyarenotpartof
thelanguageitself,sowedon'tdelveintothem.Besides,theyare
comprehensivetopicsthatdeservetheirownbooks,suchasJavaScript:
TheDefinitiveGuide,byDavidFlanagan,CGIProgrammingwithPerl,by
ScottGuelich,ShishirGundavaram,andGuntherBirzneiks,Cascading
StyleSheets:TheDefinitiveGuide,byEricMeyer,andLearningJava,by
PatNiemeyerandJonathanKnudsen(allpublishedbyO'Reilly).
ThisisyourdefinitiveguidetoHTMLandXHTMLastheyareandshould


beused,includingeveryextensionwecouldfind.Someextensionsaren't
documentedanywhere,evenintheplethoraofonlineguides.But,if

we'vemissedanything,certainlyletusknowandwe'llputitinthenext
edition.


CommentsandQuestions
Pleaseaddresscommentsandquestionsconcerningthisbooktothe
publisher:
O'Reilly&Associates,Inc.
1005GravensteinHighwayNorth
Sebastopol,CA95472
(800)998-9938(intheUnitedStatesorCanada)
(707)829-0515(international/local)
(707)829-0104(fax)
Thereisawebpageforthisbook,whichlistsanyerrata,examples,or
additionalinformation.Youcanaccessthispageat:
/>Tocommentorasktechnicalquestionsaboutthisbook,sendemailto:

Formoreinformationaboutbooks,conferences,ResourceCenters,and
theO'ReillyNetwork,seetheO'Reillywebsiteat:



Acknowledgments
Wedidnotcompose,andcertainlycouldnothavecomposed,thisbook
withoutgenerouscontributionsfrommanypeople.Ourwives,Jeanne
andCindy,andourchildren,Eva,Ethan,Courtney,andCole(they
happenedbeforewestartedwriting),formedthefrontlinesofsupport.
Andtherearenumerousneighbors,friends,andcolleagueswhohelped
bysharingideas,testingbrowsers,andlettingususetheirequipmentto
exploreHTML.Youknowwhoyouare,andwethankyouall.

Inaddition,wethankourtechnicalreviewers,EricMeyer,PatNiemeyer,
RobertEckstein,KaneScarlett,EricRaymond,andChrisTacy,for
carefullyscrutinizingourwork.Wetookmostofyourkeensuggestions.
WeespeciallythankMikeLoukides,oureditor,whohadtobringtobear
hisvastexperienceinbookpublishingtokeepustwomavericks
corralled.AndspecialthankstoDebCameronforherperseveranceand
insightinbringingboththefourthandnowthisfiftheditiontofruition.


Chapter1.HTML,XHTML,andtheWorldWide
Web
Thoughitbeganasamilitaryexperimentandspentitsadolescenceasa
sandboxforacademicsandeccentrics,inlessthanadecadethe
worldwidenetworkofcomputernetworks--alsoknownastheInternet
hasmaturedintoahighlydiversified,financiallyimportantcommunityof
computerusersandinformationvendors.Fromtheboardroomtoyour
livingroom,youcanbumpintoInternetusersofnearlyanyandall
nationalities,ofanyandallpersuasions,fromserioustofrivolous
individuals,frombusinessestononprofitorganizations,andfrombornagainChristianevangeliststopornographers.
Inmanyways,theWebtheopencommunityofhypertext-enabled
documentserversandreadersontheInternetisresponsibleforthe
meteoricriseinthenetwork'spopularity.You,too,canbecomeavalued
memberbycontributing:writingHTMLandXHTMLdocumentsandthen
makingthemavailabletowebsurfersworldwide.
Let'sclimbuptheInternetfamilytreetogainsomedeeperinsightintoits
magnificence,notonlyasanexerciseofcuriosity,buttohelpusbetter
understandjustwhoandwhatitiswearedealingwithwhenwego
online.



1.1TheInternet
Althoughpopularmediaaccountsareoftenconfusedandconfusing,the
conceptoftheInternetreallyisrathersimple:it'saworldwidecollection
ofcomputernetworksanetworkofnetworkssharingdigitalinformation
viaacommonsetofnetworkingandsoftwareprotocols.
Networksarenotnewtocomputers.WhatmakestheInternetuniqueis
itsworldwidecollectionofdigitaltelecommunicationlinksthatsharea
commonsetofcomputer-networktechnologies,protocols,and
applications.WhetheryourunMicrosoftWindowsXP,Linux,MacOSX,
oreventhenowancientWindows3.1,whenconnectedtotheInternet,
computersallspeakthesamenetworkinglanguageandusefunctionally
identicalprograms,soyoucanexchangeinformationevenmultimedia
picturesandsoundwithsomeonenextdoororacrosstheplanet.
Thecommonandnowquitefamiliarprogramspeopleuseto
communicateanddistributetheirworkovertheInternethavealsofound
theirwayintoprivateandsemi-privatenetworks.Theseso-called
intranetsandextranetsusethesamesoftware,applications,and
networkingprotocolsastheInternet.ButunliketheInternet,intranetsare
privatenetworks,withaccessrestrictedtomembersoftheinstitution.
Likewise,extranetsrestrictaccessbutusetheInternettoprovide
servicestomembers.
TheInternet,ontheotherhand,seeminglyhasnorestrictions.Anyone
withacomputerandtherightnetworkingsoftwareandconnectioncan
"getontheNet"andbeginexchangingwords,sounds,andpictureswith
othersaroundtheworld,dayornight:nomembershiprequired.And
that'spreciselywhatisconfusingabouttheInternet.
Likeanorientalbazaar,theInternetisnotwellorganized,therearefew
contentguides,anditcantakealotoftimeandtechnicalexpertisetotap
itsfullpotential.That'sbecause...


1.1.1IntheBeginning


×