preface Preface


Preface

Learning Hypertext Markup Language (HTML) and Extensible Hypertext Markup Language (XHTML) is like learning any new language, computer or human. Most students first immerse themselves in examples. Studying others is a natural way to learn, making learning easy and fun. Our advice to anyone wanting to learn HTML and XHTML is to get out there on the Web with a suitable browser and see for yourself what looks good, what's effective, and what works for you. Examine others' documents and ponder the possibilities. Mimicry is how many of the current webmasters have learned the language.

Imitation can take you only so far, though. Examples can be both good and bad. Learning by example helps you talk the talk, but not walk the walk. To become truly conversant, you must learn how to use the language appropriately in many different situations. You could learn all that by example, if you live long enough.

Computer-based languages are more explicit than human languages, though the markup languages are much more forgiving than the programming ones. Nonetheless, you typically have to get the computer language syntax correct or it won't work. There are "standards," too. Committees of academics and industry experts define the proper syntax and usage of a computer language like HTML. The problem is that the browser technologies that you and your audience use to display your documents don't always keep up with the standards. Some can't, like the limited viewers used in the burgeoning mobile-device market. And then there are those that make up their own parts to the language; standards be damned .

Standards change, besides. HTML is undergoing a conversion into XHTML, making it an application of the Extensible Markup Language (XML). HTML and XHTML are so similar that we often refer to them as a single language, but there are key differences, which we discuss later in this Preface.

To be safe, the way to become fluent in HTML and XHTML is through a comprehensive, up-to-date language reference that covers the language syntax, semantics, and variations in detail to help you distinguish between good and bad usage.

There's one more step leading to fluency in a language. To become a true master of the language, you need to develop your own style. That means knowing not only what is appropriate, but also what is effective. Layout matters. So does the order of presentation within a document, between documents, and between document collections.

Our goal in writing this book is to help you become fluent in HTML and XHTML, fully versed in their syntax, semantics, and elements of style. We take the natural-learning approach, using examples (good ones, of course). We cover in detail every element of the currently accepted standard versions of the languages (HTML 4.01 and XHTML 1.0) as well as all of the current extensions supported by the popular browsers, explaining how each element works and how it interacts with all of the other elements.

And, with all due respect to Strunk and White, throughout the book we give you suggestions for style and composition to help you decide how best to use HTML and XHTML to accomplish a variety of tasks , from simple online documentation to complex marketing and sales presentations. We show you what works and what doesn't, what makes sense to those who view your pages, and what might be confusing.

In short, this book is a definitive guide to creating documents using HTML and XHTML, starting with basic syntax and semantics and finishing with broad style guidelines to help you create beautiful, informative, accessible documents that you'll be proud to deliver to your readers.

Our Audience

We wrote this book for anyone interested in learning and using the language of the Web, from the most casual user to the full-time design professional. We don't expect you to have any experience in HTML or XHTML before picking up this book. In fact, we don't even expect that you've ever browsed the Web, although we'd be very, very surprised if you haven't. Being connected to the Internet is not strictly necessary to use this book, but if you're not connected, this book becomes like a travel guide for the homebound.

The only things we ask you to have are a computer, an editor that can create simple text files, and copies of the latest web browsers. We used the latest Internet Explorer, Mozilla Firefox, Netscape Navigator, and Opera Software ASA's Opera for the examples in this book. Because HTML and XHTML documents are stored in a universally accepted formatplain textand because the languages are completely independent of any specific computer, we won't even make an assumption about the kind of computer you're using. However, browsers do vary by platform and operating system, which means that your HTML or XHTML documents can look quite different depending on the computer and browser version. So we explain where we can how the various browsers use certain language features, paying particular attention to how they are different.

If you are new to HTML, the Web, or hypertext documentation in general, you should start by reading Chapter 1. In it, we describe how all these technologies come together to create web sites of interrelated documents.

If you are already familiar with the Web, but not with HTML or XHTML specifically , start by reading Chapter 2. This chapter is a brief overview of the most important features of the language and serves as a roadmap to how we approach the language in the remainder of the book.

Subsequent chapters deal with specific language features in a roughly top-down approach to HTML and XHTML. Read them in order for a complete tour through the language, or jump around to find the exact feature you're interested in.

Text Conventions

Throughout the book, we use a constant-width typeface to highlight any literal element of the HTML/XHTML standards, tags, and attributes. We always use lowercase letters for tags. [*] We use italic for filenames and to indicate new concepts when they are defined. Elements you need to supply when creating your own documents, such as tag attributes and user-defined strings, appear in constant-width italic in the code.

[*] HTML is case-insensitive with regard to tag and attribute names , but XHTML is case-sensitive. And some HTML items, such as source filenames, are case-sensitive, so be careful.

We discuss elements of the language throughout the book, but you'll find each one covered in depth (some might say in nauseating detail) in a shorthand, quick-reference definition box that looks like the one that follows (for the <title> element). The first line of the box contains the element name , followed by a brief description of its function. Next , we list the various attributes, if any, of the element: those things that you may or must specify as part of the element.

<title>

Function

Defines the document title

Attribute

dirlang

End tag

</title> ; never omitted

Contains

plain_text

Used in

head_content



The icon identifies tags and attributes that aren't in the HTML 4.01 or XHTML 1.0 standards, and those that are handled very differently between the various popular browsers.

The description also includes the HTML ending tag, if any, for the element, along with a general indication of whether the end tag may be safely omitted in general use in HTML. For the few tags that require end tags in XHTML, but do not have them in HTML, the language lets you indicate that by placing a forward slash ( / ) before the tag's closing bracket , as in <br/> . In these cases, the tag may also contain attributes, indicated with an intervening ellipsis, such as <br ... /> .

The "Contains" header names the rule in the HTML grammar that defines the elements to be placed within this tag. Similarly, the "Used in" header lists those rules that allow this tag as part of their content. We define these rules in Appendix A.

Finally, HTML and XHTML are fairly intertwined languages. You will occasionally use elements in different ways depending on context, and many elements share identical attributes. Wherever possible, we place a cross-reference in the text that leads you to a related discussion elsewhere in the book. These cross-references, like the one at the end of this paragraph, serve as a crude paper model of hypertext documentation, one that would be replaced with a true hypertext link should this book be delivered in an electronic format. [The Syntax of a Tag, 3.3.1]

We encourage you to follow these cross-references whenever possible. Often, we cover an attribute briefly and expect you to jump to the cross-reference for a more detailed discussion. In other cases, following the link takes you to alternative uses of the element under discussion or to style and usage suggestions that relate to the current element.

Versions and Semantics

The latest HTML standard is version 4.01, but most updates and changes to the language standard were made in version 4.0. Therefore, throughout the book, we often refer to the HTML standard as HTML 4, encompassing versions 4.0 and later. We explicitly state the "dot" version number only when it is relevant.

The XHTML standard is currently in its first iteration, 1.0. The World Wide Web Consortium (W3C) has released a Working Draft of a second version (XHTML 2.0), but the standard is yet established. For the most part, XHTML 1.0 is identical to HTML 4.01; we detail their differences in Chapter 16. Throughout the book, we specifically note cases where XHTML handles a feature or element differently than the original language, HTML.

The HTML and XHTML standards make very clear the distinction between "element types" of a document and the markup "tags" that delimit those elements. For example, the standard refers to the paragraph element type, which is not the same as the <p> tag. The paragraph element consists of the accepted element-type name within the starting tag ( <p> ), intervening content, and the ending paragraph tag ( </p> ). The <p> tag is the starting tag for the paragraph element, and its contents, known as attributes, ultimately affect the paragraph element type's contents.

Although these are important distinctions, we're pragmatists. It is the markup tag that authors apply in their documents and that affects any intervening content. Accordingly, throughout the book, we relax the distinction between element types and tags, often talking about tags and all related contents and not necessarily using the term element-type when it would be technically appropriate to make the distinction. Forgive us the transgression, but we do so for the sake of clarity.

HTML Versus XHTML

It's not Latin, but HTML has reached old age in standard version 4.01. The W3C has no plans to develop another version and has officially said so. Rather, HTML is being subsumed and modularized as an Extensible Markup Language (XML). Its new name is XHTML, Extensible Hyptertext Markup Language.

The emergence of XHTML is just another chapter in the often tumultuous history of HTML and the Web, where confusion for authors is the norm, not the exception. At its nadir, the elders of the W3C responsible for accepted and acceptable uses of the languagestandardslost control of the language in the browser "wars" between Netscape and Microsoft. The abortive HTML+ standard never got off the ground, and HTML 3.0 became so bogged down in debate that the W3C simply shelved the entire draft. HTML 3.0 never happened , despite what some opportunistic marketers claimed in their literature. Instead, by late 1996, the browser manufacturers convinced the W3C to release HTML standard version 3.2, which for all intents and purposes simply standardized most of Netscape's HTML extensions.

Netscape's dominance as the leading browser, and as a leader in web technologies, faded dramatically toward the end of the millennium . By then, Microsoft had effectively bundled Internet Explorer into the Windows operating system, not only as an installed application, but also as a dominant feature of the GUI desktop. In addition, Internet Explorer introduced several features (albeit nonstandard at the time) that appealed principally to the growing Internet business and marketing community.

Fortunately for those of us who appreciate and strongly support standards, the W3C took back its primacy role with HTML 4.0, which stands today as HTML version 4.01, released in December 1999. Absorbing many of the Netscape and Internet Explorer innovations, the standard is clearer and cleaner than any previous ones, establishes solid implementation models for consistency across browsers and platforms, provides strong support and incentives for the companion Cascading Style Sheets (CSS) standard for HTML-based displays, and makes provisions for alternative (nonvisual) user agents , as well as for more universal language supports.

Cleaner and clearer aside, the W3C realized that HTML could never keep up with the demands of the web community for more ways to distribute, process, and display documents. HTML offers only a limited set of document-creation primitives and is hopelessly incapable of handling nontraditional content like chemical formulae, musical notation, and mathematical expressions. Nor can it well support alternative display media, such as handheld computers and intelligent cellular phones.

To address these demands, the W3C developed the XML standard. XML provides a way to create new, standards-based markup languages that don't take an act of the W3C to implement. XML-compliant languages deliver information that can be parsed, processed , displayed, sliced, and diced by the many different communication technologies that have emerged since the Web sparked the digital communication revolution a decade ago. XHTML is HTML reformulated to adhere to the XML standard. It is the foundation language for the future of the Web.

Why not just drop HTML for XHTML? For many reasons. First and foremost, XHTML has not exactly taken the Web by storm . There's just too much current investment in HTML-based documentation and expertise for that to happen anytime soon. Besides, XHTML is HTML 4.01 reformulated as an application of XML. Know HTML 4 and you're all ready for the future. [*]

[*] We plumb the depths of XML and XHTML in Chapters 15 and 16.

Deprecated Features

One of the unpopular things standards bearers have to do is make choices between popular and proper. The authors of the HTML and XHTML standards exercise that responsibility by "deprecating" those features of the language that interfere in the grand scheme of things.

For instance, the <center> tag tells the browser to display the enclosed text centered in the display window. But the CSS standard provides ways to center text, too. The W3C chooses to support the CSS way and discourages the use of <center> by deprecating the tag. The plan is, in some later standard version, to stop using <center> and other deprecated elements and attributes of the language.

Throughout the book, we specially note and continuously remind you when an HTML tag or other component is deprecated in the current standards. Should you stop using them now? Yes and no.

Yes, because there is a preferred and perhaps better way to accomplish the same thing. By exercising that alternative, you ensure that your documents will survive for many years to come on the Web. And, yes, because the tools you may use to prepare HTML/XHTML documents probably adhere to the preferred standard. You may not have a choice, unless you disable your tools. In any event, unless you hand-compose all your documents, you'll need to know how the preferred way works so that you can identify the code and modify it.

However compelling the reasons for not using deprecated elements and attributes are, they still are part of the standards. They remain well supported by most browsers and aren't expected to disappear anytime soon. In fact, since there is no plan to change the HTML standard, the "deprecated" stamp is very misleading.

So, no, you don't have to worry about deprecated HTML features. There is no reason to panic, certainly . We do, however, encourage you to make a move toward the standards soon.

A Definitive Guide

The paradox in all this is that even the HTML 4.01 standard is not the definitive resource. There are many more features of HTML in popular use and supported by the popular browsers than are included in the latest language standard. And there are many parts of the standards that are ignored. We promise you, things can get downright confusing.

We've managed to sort things out for you, though, so you don't have to sweat over what works and doesn't work with what browser. This book, therefore, is the definitive guide to HTML and XHTML. We give details for all the elements of the HTML 4.01 and XHTML 1.0 standards, plus the variety of interesting and useful extensions to the language. We also include detailed discussions of the CSS standard, since it is so intricately related to web page development.

In addition, there are a few things that are closely related but not directly part of HTML. For example, we touch, but do not handle, JavaScript, Common Gateway Interface (CGI), and Java programming. They all work closely with HTML documents and run with or alongside browsers, but they are not part of the language itself, so we don't delve into them. Besides, they are comprehensive topics that deserve their own books, such as JavaScript: The Definitive Guide , by David Flanagan; CGI Programming with Perl , by Scott Guelich, Shishir Gundavaram, and Gunther Birzneiks; Cascading Style Sheets: The Definitive Guide , by Eric Meyer; and Learning Java , by Pat Niemeyer and Jonathan Knudsen (all published by O'Reilly).

This is your definitive guide to HTML and XHTML as they are and should be used, including every extension we could find. Some extensions aren't documented anywhere , even in the plethora of online guides. But, if we've missed anything, certainly let us know and we'll put it in the next edition.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product's documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: " HTML & XHTML: The Definitive Guide , Sixth Edition, by Chuck Musciano and Bill Kennedy. Copyright 2007 O'Reilly Media, Inc., 978-0-596-52732-7."

Safari Enabled

When you see a Safari Enabled icon on the cover of your favorite technology book, that means the book is available online through the O'Reilly Network Safari Bookshelf.

Safari offers a solution that's better than e-books. It's a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.

Comments and Questions

Please address comments and questions concerning this book to the publisher:

O'Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international/local)
707-829-0104 (fax)

There is a web page for this book, which lists any errata, examples, or additional information. You can access this page at:

http://www.oreilly.com/catalog/html6

To comment or ask technical questions about this book, send email to:

bookquestions@oreilly.com

For more information about books, conferences, Resource Centers, and the O'Reilly Network, see the O'Reilly web site at:

http://www.oreilly.com

Acknowledgments

We did not compose, and certainly could not have composed , this or any other edition of the book without generous contributions from many people. Our wives, Jeanne and Cindy, and our children, Eva, Ethan, Courtney, and Cole (they happened before we started writing), formed the front lines of support. And there are numerous neighbors, friends , and colleagues who helped by sharing ideas, testing browsers, and letting us use their equipment to explore HTML. You know who you are, and we thank you all.

In addition, we thank our technical reviewers, Chat Clussman, Patrick Krekelberg, Sam Marshall, and Shlomi Fish, for carefully scrutinizing our work. We took most of your keen suggestions. We especially thank our O'Reilly editors, especially Mike Loukides and Tatiana Apandi, for their patience in keeping us two mavericks corralled. And special thanks to Tatiana for bringing this sixth edition to fruition.



HTML & XHTML(c) The definitive guide
Data Networks: Routing, Security, and Performance Optimization
ISBN: 596527322
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Tony Kenyon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net