- Shopping Bag ( 0 items )
Ships from: Lindenhurst, NY
Usually ships in 1-2 business days
Ships from: FORT MYERS, FL
Usually ships in 1-2 business days
Ships from: fallbrook, CA
Usually ships in 1-2 business days
Master the Core of All Web Development—And Prepare for the Future
In this chapter, we'll introduce you to HTML and XHTML, which, as you'll see, are markup languages that you can use to develop documents for a variety of online uses. This chapter aims to help you build the vocabulary and basic understanding you'll need to actually use HTML and XHTML.
Specifically, in this chapter you'll find the following topics:
* Identifying uses for HTML and XHTML
* Understanding the difference between HTML and XHTML
* Determining whether HTML or XHTML is better for your needs
* Learning the tools you need to use HTML and XHTML
* Recognizing HTML and XHTML code
* Applying HTML and XHTML markup correctly
* Applying rules specific to XHTML markup
* Accessing other HTML and XHTML resources
Why Use HTML or XHTML?
HTML and XHTML are both markup languages. A markup language is a system of codes that identify parts and characteristics of documents published online. Before you say, "Yikes, that sounds techie!" consider that you're probably already familiar with the most common application for HTML and XHTML-Web pages. HTML and XHTML are not what you see on screen as a Web page; instead, they're the behind-the-scenes "code" that tells Web browsers what to display.
Let's look at some possible uses for HTML and XHTML:
Developing Web sites Using HTML- or XHTML-developed Web pages and sites, users can jump from topic to topic, view images, fill out forms, submit information, and search databases, among many other possibilities. Basically, these markup languages provide many of the capabilities and functionality that you're accustomed to using when you visit Web sites.
Developing intranet or extranet sites HTML and XHTML are commonly used to develop intranet sites-Web sites accessed by people within a company or organization from one or more locations-or extranet sites, used by people from a specific group of companies or organizations that routinely share information among themselves.
Creating help files or documentation HTML and XHTML can also be used to develop online help files that are accessible on any platform. Online help files allow developers to produce documentation inexpensively.
Developing network applications HTML and XHTML are even used for developing applications, such as training programs or online classes, or for providing access to databases through Web pages.
Developing kiosk applications You can also use HTML and XHTML to help implement kiosk applications-those stand-alone computers with the neat touch-screen capabilities.
Delivering information via wireless devices HTML and XHTML can be used to display documents on a variety of wireless devices, including Web-enabled phones, personal digital assistants, and handheld computers. It's expected that this will be an area of tremendous growth over the next few years.
What's the Difference Between HTML and XHTML?
In general, you'll find that HTML and XHTML are very similar, and most Web browsers handle both equally well. The main differences include:
XHTML is pickier about how you type the code (the markup) into the documents. As you'll see later in this chapter, XHTML requires your documents and markup to follow very specific rules. For example, whereas HTML lets you use uppercase, lowercase, or a combination of the two when marking up your documents, XHTML requires that you use only lowercase letters. Similarly, although you can get away with using only an opening element in HTML-say, using just an opening paragraph element (
) to mark a paragraph-XHTML requires that you always use both opening and closing tags, like this:
.... These XHTML rules aren't hard to learn or follow, but you will need to pay special attention as you develop XHTML documents and make sure all of the details are accurate and complete.
Note If you're familiar with HTML, you're probably used to hearing the word tag to describe HTML markup. You might think of tags as being generally equivalent to "elements," with "tag" being the less formal term. Technically, the tag (or tag pair) refers to the elements and the surrounding <> and </> characters. Throughout this book, we'll generally use the term element to refer to both the perhaps more familiar "tag" and the more accurate "element," unless we particularly need to emphasize the components of a tag-as we will later in this chapter.
XHTML can provide more capabilities and flexibility than HTML does. XHTML is based on a larger markup language called XML (Extensible Markup Language, which we'll cover in Part VI), which provides developers with powerful capabilities and flexibility far beyond what HTML offers. For example, suppose you want to automatically generate a table of contents for your Web site pages. Because XHTML documents have more structure and are more predictable than HTML documents, you'll find that automatically extracting specific pieces of XHTML documents to generate this content is easier than extracting specific pieces of HTML. In general, XHTML gives you a bit more power and flexibility than you have with straight HTML, yet it doesn't have XML's steep learning curve.
XHTML can provide a good start if you or your company may move to using a more structured markup language in the future. While XHTML doesn't have the depth of structure that XML or SGML (Standard Generalized Markup Language) offers, it does have basic documentlevel structure and regularity. So, while transferring from using XHTML to one of these markup languages is a complex undertaking, XHTML will give you a far better start than HTML would.
So, are we saying that you should choose XHTML rather than HTML? The short answer is that, really, there's no reason not to use XHTML. In fact, we would encourage you (even if you're new to markup languages or new to developing documents for online uses) to use XHTML. It's not that much harder to learn and use than HTML, following the rules can provide you with some good planning and document-development skills, and it gives you future options and flexibility.
Tip Web browsers handle HTML and XHTML equally well, and XHTML is not much more difficult to implement than HTML (and it's more flexible). So, we recommend using XHTML in most cases.
The long answer is, first consider what your needs are. Are you developing a simple personal Web site? Documents for an intranet or extranet site where only HTML is being used? Documents that have to be developed as quickly as possible, then will be discarded shortly thereafter? Or documents that will need to be maintained by very un-technical folks? If so, then HTML might be the better choice for you.
If, however, you are developing more than a minimal Web site, a site that will likely require some amount of maintenance or revision, or a site in which other parts are already using XHTML, then using XHTML is highly recommended. Similarly, if you're developing documents for online help, kiosks, or wireless devices, we'd highly recommend using XHTML simply because it's more flexible, forward-looking, and compatible with XML (on which XHTML is based).
Note Throughout this book, we'll be primarily using XHTML for examples of documents and code. Note that these examples will work equally well whether you're using HTML or XHTML.
Where Did HTML and XHTML Come From?
The roots of HTML (which is the predecessor to XHTML) go back to the late 1980s and early 1990s. That's when Tim Berners-Lee first developed HTML to provide a simple way for scientists at CERN (a particle physics laboratory in Geneva, Switzerland) to exchange reports and research results on the Web. HTML is based on a formal definition created using a powerful meta-language-a language used to create other languages-called the Standard Generalized Markup Language (SGML). SGML is an International Organization for Standardization (ISO) standard tool designed to create markup languages of many kinds. By the early 1990s, the power and reach of the World Wide Web was becoming well known, and CERN released HTML for unrestricted public use. CERN eventually turned HTML over to an industry group called the World Wide Web Consortium (W3C), which continues to govern HTML and related markup-language specifications. Public release of HTML (and its companion protocol, the Hypertext Transfer Protocol, or HTTP, which is what browsers use to request Web pages, and what Web servers use to respond to such requests) launched the Web revolution that has changed the face of computing and the Internet forever. In the years since HTML became a public standard, HTML has been the focus of great interest, attention, and use. The original definition of HTML provided a way for us to identify and mark up content-specific information judged to be of sufficient importance to deliver online-without worrying too much about how that information looked, or how it was presented and formatted on the user's computer display. But as commercial interest in the Web exploded, graphic designers and typographers involved in Web design found themselves wishing for the kind of presentation and layout controls that they received from software such as PageMaker and QuarkXPress. HTML was never designed as a full-fledged presentation tool, but it was being pulled strongly in that direction, often by browser vendors, such as Microsoft and Netscape, who sought market share for their software by accommodating the desires of their audience. Unfortunately, these browser-specific implementations resulted in variations in the HTML language definitions that weren't supported by all browsers and resulted in functionality that wasn't part of any official HTML language definition. Web designers found themselves in a pickle-forced either to build Web pages for the lowest common denominator that all browsers could support, or to build Web pages that targeted specific browsers that not all users could necessarily view or appreciate. Basically, XHTML was created as a means to address this discrepancy. XHTML provides a way to take advantage of a newer, more compact underlying meta-language called XML (Extensible Markup Language) that is inherently extensible and, therefore, open-ended. More important, XHTML helps rationalize and consolidate a Web markup landscape that had become highly fragmented (a result of different and incompatible implementations of HTML). There are many other good reasons for using standard-compliant HTML or XHTML, and you'll learn more about them later in this chapter and throughout this book. The HTML and XHTML specifications-all versions, revisions, and updates-are maintained by the W3C and can be found at w3.org. Taking a tour through the W3C Web pages can be quite useful, in terms of learning what issues are considered most pressing or least important to the people making the specifications. In addition, you can find out if your personal concerns are being addressed. At the time this book was written, the primary issues being addressed by the HTML Working Group were pushing XHTML in the direction of modularization (Chapter 25) and toward use of Schemas (Chapter 29, on the Web). Both of these issues reflect the importance of moving HTML toward standards that are:
* Compatible with existing browsers and tools
* Flexible enough to accommodate non-traditional browsers, like handheld computers and Web-enabled cell phones
* Consistent and predictable enough to be readily parsed and processed by Web servers and other programs to provide tailored content
That said, you do not need to worry about the future of HTML as you know it. No plans are under way to make any changes or improvements to HTML 4.01, and XHTML 1.0 is explicitly defined as being a "reformulation" of HTML 4.01 in XML; therefore, your investment of time and effort in learning HTML or XHTML won't be wasted. In our opinion, given the number of Web pages out there, there's virtually no possibility that HTML 4.01 or XHTML will change substantially or cease to exist in the next several years-high-end Web sites and information delivery systems will evolve to take advantage of the new features that the W3C defines, but all of the basics (for example, everything in this book) will continue to work for the foreseeable future. You'll find more history about markup languages in Chapter 21, which discusses XML in the context of how it fits into HTML and SGML (Standard Generalized Markup Language).
What Tools Do You Need?
Whether you're planning to develop HTML or XHTML documents, you'll need three basic tools:
* A plain-vanilla text editor, which you will use to create and save your documents. The "HTML and XHTML Editors" sidebar provides more information about some of the editors that are available; however, keep in mind that we highly recommend using a plain-text editor for developing HTML and XHTML documents-at least when you're learning to use these markup languages.
* A Web browser, which you will use to view and test your documents. In fact, you should have multiple Web browsers available so that you can see how your documents look when viewed in these different browsers.
* A validator, which you will use to verify that your HTML or XHTML documents are developed and coded correctly. We recommend using a validator if you're developing HTML documents; however, because browsers can often display HTML code that's a bit sloppy or not completely "standard," validating your HTML documents isn't an absolute must. If you're developing XHTML documents, however, you must use a validator as part of your documentdevelopment and publishing process. The XHTML standard has specific rules to follow, and if you want to use XHTML, you must ensure that your XHTML code is applied correctly.
Let's take a more in-depth look at these necessary tools.
Text editors force you to hand-code, meaning that you, not the software, enter the code. Hand-coding helps you learn HTML and XHTML elements, attributes, and structures, and it lets you see exactly where you've made mistakes. Also, with hand-coding, you can easily include the newest enhancements in your documents, whereas WYSIWYG editors don't have those enhancements available until updated product versions are released.
Some basic text editors are:
* Notepad for all Windows versions
* vi or pico (command line), or GEdit or Kate (GUI) for Linux/Unix
* TeachText or SimpleText for Macintosh
Warning Using a word processing program such as Word, StarOffice, or even WordPad to create HTML documents often inadvertently introduces unwanted formatting and control characters, which can cause problems. HTML and XHTML require plain text, so either make a special effort to save all documents as plain text within such applications, or take our advice and use a text editor instead.
HTML and XHTML Editors
In general, editors fall into two categories:
Text- or code-based editors, which show you the HTML or XHTML code as you're creating documents A variety of code-based HTML and XHTML editors exist for Windows, Macintosh, and Linux/Unix, and most of them are fairly easy to use (and create HTML code just as you wrote it). That said, as we write this chapter, few editors are available that produce XHTML code (or rigorously standardcompliant HTML code, for that matter). However, it's possible to use an HTML editor or a simple text editor to create an initial version of your XHTML documents and then to make use of a special-purpose tool, such as HTML Tidy or HTML-Kit, to transform your HTML into equivalent, properly formatted XHTML. Because this requires a bit more savvy than we assume from our general readership, this material is aimed only at those more experienced readers to whom this kind of approach makes sense.
WYSIWYG ("What You See Is What You Get") editors, which show the results of code, similar to the way it will appear in a browser, as you're formatting your document Simple WYSIWYG editors, such as Netscape Composer and Microsoft FrontPage Express, are good for quickly generating HTML documents. These editors give you a close approximation of page layout, design, and colors, and are good for viewing the general arrangement of features. However, they do not give you as much control over the final appearance of your document as code-based editors do. Additionally, although there have been improvements over the last couple of years, WYSIWYG editors notoriously introduce unneeded elements, non-compliant code, and other characteristics that purists object to.
After you've developed a few HTML documents and understand basic HTML principles, you may choose to use both a WYSIWYG editor and a code-based editor. For example, you can get a good start on your document using a WYSIWYG HTML editor and then polish it (or fix it) using a code-based one. Others prefer Web editing/publishing tools like Dreamweaver, which offers a combined approach with both WYSIWYG and code-based modes.
For now, though, we recommend that you hand-code HTML and XHTML using a plain-text editor.
Excerpted from Mastering HTML and XHTML by Deborah S. Ray Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.
|Pt. 1||Getting Started||1|
|Ch. 1||Getting Acquainted with HTML and XHTML||3|
|Ch. 2||Creating Your First HTML or XHTML Document||25|
|Ch. 3||Linking Your Documents||57|
|Ch. 4||Including Images||73|
|Pt. 2||Advancing Your Skills||107|
|Ch. 5||Developing Tables||109|
|Ch. 6||Developing Forms||141|
|Ch. 7||Creating Frames||177|
|Ch. 8||Converting HTML to XHTML||213|
|Pt. 3||Moving Beyond Pure HTML and XHTML||229|
|Ch. 9||Using Style Sheets||231|
|Ch. 11||Including Multimedia||303|
|Pt. 4||Developing Web Sites||321|
|Ch. 12||Planning for a Coherent, Usable, Maintainable, and Accessible Web Site||323|
|Ch. 13||Implementing a Good Web Site||355|
|Ch. 14||Tips for Web Sites: Public, Personal, and Intranet||369|
|Ch. 15||Publishing Your XHTML Documents||393|
|Pt. 5||Applying HTML and XHTML to Advanced Applications||407|
|Ch. 16||Bringing Pages to Life with Dynamic HTML and XHTML||409|
|Ch. 17||Generating HTML or XHTML from a Database||433|
|Ch. 18||Making Your Web Site Searchable||443|
|Pt. 6||HTML and XHTML Development Tools||457|
|Ch. 19||Choosing Development Tools||459|
|Ch. 20||Validating HTML and XHTML Documents||467|
|Pt. 7||A Bridge to XML||481|
|Ch. 21||An Overview of XML||483|
|Ch. 22||Extending XHTML Using Namespaces||499|
|Ch. 23||Getting Started with DTDs||515|
|Ch. 24||Creating a DTD||527|
|Ch. 25||XHTML 1.1 and XHTML Modularization||547|
|Pt. 8||The XML Family of Applications||585|
|Ch. 26||XSLT: Extensible Stylesheet Language Transformations||587|
|Ch. 28||XML Tree Model Reference||647|
|Ch. 29||XML Schemas||657|
|Pt. 9||Master's Reference||685|
|Master's Reference Part 1: HTML and XHTML Elements and Attributes||687|
|Master's Reference Part 2: Cascading Style Sheets Reference||847|
|Master's Reference Part 3: Scripting Reference||921|
|Master's Reference Part 4: HTML and XHTML Special Characters||1037|
|Master's Reference Part 5: Color Codes||1051|