HTML, DHTML, Java Script
HTML, DHTML, Java Script
BY MILAN KOTHARI
CHAPTER 1................................................................... 11
What is HTML? ....................................................................................11
HTML at a Crossroads..........................................................................11
HTML is not a Programming Language ................................................11
A Short HTML History ..........................................................................12
Marking Up Text ..................................................................................13
Who Decides What HTML Is?...............................................................13
The HTML Working Group....................................................................14
The World Wide Web Consortium ........................................................14
Individual Companies and HTML .........................................................14
Additional Information on HTML Standards and Organizations ...........15
Summary.............................................................................................15
Review Questions................................................................................15
CHAPTER 2................................................................... 16
The World Wide Web and Web Servers ...............................................16
What's the World Wide Web? ..............................................................16
The Hypertext Concept: Web Links......................................................16
Example: Thinking in Hypertext ..........................................................17
The Web Page ..................................................................................17
The Web Site .......................................................................................17
Example: A Corporate Web Site ........................................................18
Intranets vs. the Internet ...................................................................18
Hypermedia: Text and Graphics on the Web........................................18
Helper Applications ..........................................................................19
Common Multimedia Formats..............................................................19
Internet Services and Addresses.........................................................20
Internet E-mail.................................................................................20
Table 2.2 Common First-Level Domain Names.................................21
UseNet Newsgroups .........................................................................22
Table 2.3 Common UseNet First-Level Newsgroup Names...............23
Gopher and WAIS .............................................................................23
FTP ...................................................................................................23
Summary.............................................................................................24
Review Questions................................................................................24
Review Exercises ................................................................................25
CHAPTER 3................................................................... 26
How Web Browsers Work....................................................................26
Web Browser Applications ..................................................................26
NCSA Mosaic .......................................................................................26
Netscape Navigator.............................................................................26
Microsoft Internet Explorer.................................................................28
Lynx ....................................................................................................28
Chapter 1
What is HTML?
The explosive growth of the World Wide Web is relatively unprecedented, although it resembles the
desktop publishing revolution of the early and mid-1980s. As personal computers became more
common in homes and offices, people began to learn to use them for document creation and page
layout. Although early word processing programs were not terribly intuitive and often required
memorizing bizarre codes, people still picked them up fairly easily and managed to create their own in-
house publications.
Suddenly, the same kind of growth is being seen as folks rush to create and publish pages of a different
sort. To do this, they need to learn to use something called the Hypertext Mark-up Language (HTML).
HTML at a Crossroads
HTML and the World Wide Web in general are currently in a stage of development similar to that of
the desktop publishing revolution. Still working to reach maturity as a standard, HTML is feeling the
same growing pains that early word processing programs did-as more users flock to HTML, there is a
growing need to standardize it and make it less complex to implement.
These days, word processors are much more intuitive than they were 15 years ago. There are fewer
codes and special keystrokes required to get something done. The applications have matured to the
point where most of the low-level formatting is kept hidden from the user of the application. At the
same time, the printed page is now more completely mirrored on the computer screen, with accurately
represented fonts, emphasis, line breaks, margins, and paragraph breaks.
Although programs are quickly being developed to offer similar features for HTML development,
these tend to be less than ideal solutions. Currently then, anyone who decides to learn HTML is going
to have to know some codes, memorize some syntax, and develop pages for the World Wide Web
without the benefit of seeing all the fonts, emphasis, and paragraph breaks beforehand.
But anyone who has had any success with word processing programs of ten or 15 years ago (or desktop
publishing programs as recently as five years ago) will have little or no trouble learning HTML.
Ultimately, you'll see that HTML's basic structure makes a lot of sense for this emerging medium-the
World Wide Web. And, as with most things computer-oriented, you'll find that once you've spent a few
moments with it, HTML isn't nearly as difficult as you might have originally imagined.
There's nothing I'd like more than to say: "Yes, HTML is a very difficult programming language that
has taken me years to master. So I'll have to charge $75 an hour to develop your Web pages for you."
Unfortunately, it's simply not the case. As I've already hinted, creating an HTML document is not
much more difficult than using a ten-year-old copy of WordPerfect with the Reveal Codes setting
engaged.
Tip
Remember the definition of HTML: Hypertext Mark-up Language. In HTML
itself, there is no programming-just the "marking up" of regular text for emphasis
and organization.
In fact, I prefer to call people who work with HTML "designers" or "developers," and not
programmers. Actually, there's only limited design work that can be accomplished with HTML
(especially the most basic standards of HTML), and anyone used to working with FrameMaker,
QuarkXPress, or Adobe PageMaker will be more than a little frustrated. But the best pages are still
those created by professional artists, writers, and others with a strong sense of design.
As Web page development matures, we are starting to see more concessions to the professional
designers, as well as an expansion into realms that do require a certain level of computer programming
expertise. Creating scripts or applets (small programs) in the Java language, for instance, is an area
where Web page development meets computer programming. It's also a relatively distinct arena from
HTML, and you can easily be an expert in HTML without ever programming much of anything.
The basics of HTML are not programming, and, for the uninitiated in both realms, HTML is much
more easily grasped than are most programming languages. If you're familiar with the World Wide
Web, you've used a Web browser like Netscape, Mosaic, or Lynx; and if you have any experience with
a word processor or text editor like WordPad, Notepad, SimpleText, or Emacs, then you're familiar
with the basic tools required for learning HTML.
HTML developed a few years ago as a subset of SGML (Standard Generalized Mark-up Language)
which is a higher-level mark-up language that has long been a favorite of the Department of Defense.
Like HTML, it describes formatting and hypertext links, and it defines different components of a
document. HTML is definitely the simpler of the two, and although they are related, there are few
browsers that support both.
Because HTML was conceived for transmission over the Internet (in the form of Web pages), it is
much simpler than SGML, which is more of an application-oriented document format. While it's true
that many programs can load, edit, create, and save files in the SGML format (just as many programs
can create and save programs in the Microsoft Word format), SGML is not exactly ideal for
transmission across the Internet to many different types of computers, users, and browser applications.
HTML is more suited to this task. Designed with these considerations in mind, HTML lets you, the
designer, create pages that you are reasonably sure can be read by the entire population of the Web.
Even users who are unable to view your graphics, for instance, can experience the bulk of what you're
communicating if you design your HTML pages properly.
At the same time, HTML is a simple enough format (at least currently) that typical computer users can
generate HTML documents without the benefit of a special application. Creating a WordPerfect-format
document would be rather difficult by hand (including all of the required text size, fonts, page breaks,
columns, margins, and other information), even if it weren't a "proprietary"-that is, nonpublic-
document format.
Marking Up Text
The most basic element of any HTML page (and, therefore, any page on the Web) is ASCII text. In
fact, although it's slightly bad form, a single paragraph of regular text-generated in a text editor and
saved as a text file-can be displayed in a Web browser with no additional codes or markings An
example of this might simply be:
Welcome to my home on the World Wide Web. As you can see, my page isn't
completely developed yet, but there were some things I simply had to say
before I could get anything else done. My name is Emmanuel Richards, and
I'm a real estate developer located in the San Fernando Valley. If you'd
like, you can reach my office at 555-4675.
Remember that HTML-formatted documents aren't that far removed from documents created by a
word processing program, which are also basically text. Marking up text, then, simply means you add
certain commands, or tags, to your document in order to tell a Web browser how you want the
document displayed.
One of the most basic uses for HTML tags is to tell a browser that you want certain text to be
emphasized on the page. The HTML document standard allows for a couple of different types of
emphasis including explicit formatting, where you choose to make something italic as opposed to bold,
or implicit formatting, where it's up to the browser to decide how to format the emphasized text.
Using part of the example above, then, an HTML tag used for emphasis might look something like
this:
In this example, <EM> and </EM> are HTML tags that tell the Web browser which text (in this example,
my home) is to be emphasized when displayed.
The browser isn't just displaying regular text; it has also taken into account the way you want the text
to be displayed according to the HTML tags you've added. Tags are a lot like margin notes you might
make with a red pen when editing or correcting term papers or corporate reports. After you've entered
the basic text in a Web document, you add HTML mark-up elements to tell the browser how you want
things organized and displayed on the page.
In most word processing documents, the "mark up" that describes the emphasis and organization of
text is hidden from the user. HTML, however, is a little more primitive than that, as it allows you to
manually enter your text mark-up tags to determine how the text will appear. You can't do this with an
MS Word document, but, then again, MS Word documents aren't the standard for all Web pages and
browsers on the Internet!
The HTML standard is maintained and debated by a group called the HTML Working Group, which,
in turn, is a creation of the Internet Engineering Task Force. The Working Group was charged in 1994
with the task of defining the HTML standard that was in widespread use on the Web at the time
(known as HTML 2.0), and then submitting proposals for future standards, including the HTML 3.0
standard.
Up until the spring of 1996, the Working Group seemed to be the bearer of the basic standard for
HTML around the world, while others work to agree on standards for other Web-oriented technologies
that have a cursory relationship-like graphics formats, digital movies, sounds, and emerging Web
languages such as Java and VRML (Virtual Reality Modeling Language). Now, nearly all
responsibility for future Web development will most likely fall to an industry cooperative called the
W3 Consortium.
HTML was originated by Tim Berners-Lee, with revisions and editing by Dan Connolly and Karen
Muldrow. Up until the time when the Working Group took over responsibility for the standard, it was
largely an informal effort.
Still very much involved in the evolution of the standard is Tim Berners-Lee, who now serves as
director of the World Wide Web Consortium (W3C)-a group of corporations and other organizations
with an interest in the World Wide Web. The group is run by the Laboratory for Computer Science at
MIT, and includes members such as AT&T, America Online, CompuServe, Netscape Communications
Corp., Microsoft Corp., Hewlett Packard, IBM, and many others.
Here, member organizations get together to iron out differences over Web-related standards and
practices while working to maintain some level of standardization between their products. Corporate
self-interest can sometimes get in the way, but it is definitely of utmost importance to most of these
organizations that their products stay abreast of the most popular standards, and that their customers
are fully able to take advantage of the Web.
Some notable deviations from the standard are the extensions, or additional commands, that Netscape
Communications Corp. has added to HTML 2.0 (see fig. 1.3). Only Netscape's browsers (and those
written to be compatible with Netscape's products) can view all of these extensions, and some of them
have yet to be recognized by the HTML Working Group. Netscape can get away with this, though,
since it controls somewhere around 60 percent of the World Wide Web browser market.
Other companies, notably Microsoft, have also distributed Web browsers-in Microsoft's case, the
Internet Explorer-that offer enhancements over the agreed-upon HTML standards, and acceptance of
those extensions by a majority of Web designers may further sway groups like the HTML Working
Group.
Most of the HTML standard bodies and organizations maintain an active presence on the World Wide
Web, and information about these groups and their work can be found in many places.
For more on the World Wide Web Consortium, consult the W3C Web site at http:/www.w3.org/. This
site will probably be the most useful as you continue to learn more about HTML and emerging new
standards.
Summary
HTML is a document format, somewhat like word processing or desktop publishing formats, but
considerably less complicated and based on more open standards. Creating HTML programs isn't
really programming-although some programming can be necessary in other aspects of Web page
creation. There are a few different organizations that make it their business to oversee the HTML
standard, but the standard can just as easily be affected by the software companies that write Web
browsers. The standard is also influenced very much by what commands and layout features Web
designers implement, and what commands they ignore.
Review Questions
Chapter 2
The World Wide Web and Web Servers
Probably the most important thing to remember about the World Wide Web and the Internet in general
is that they are global in scale and often a very cooperative venture. Information on the Web tends to
be distributed around the world, and it's just as easy for you to access a site in New Zealand or Japan as
it is to access Web information in your own state.
The basic reason for learning HTML is to create pages for the World Wide Web. Before you start,
though, you'll want to know a little about how this whole process works. We'll begin by taking a look
at Web browsing programs, then we'll talk about how the World Wide Web works, and we'll discuss
some of the terms associated with surfing the Web. Finally, we'll round out the discussion by talking
about the Internet in general and the different services available on the Internet and how they interact
with the Web.
The World Wide Web is an Internet service, based on a common set of protocols, which allows a
particularly configured server computer to distribute documents across the Internet in a standard way.
This Web standard allows programs on many different computer platforms (such as UNIX, Windows
95, and the Mac OS) to properly format and display the information served. These programs are called
Web browsers.
The Web is fairly unique among Internet services (which include Internet e-mail, Gopher, and FTP) in
that its protocols allow for the Web server to send information of many different types (text, sound,
graphics), as well as offer access to those other Internet services. Most Web browsers are just as
capable of displaying UseNet newsgroup messages and Gopher sites as they are able to display Web
pages written in HTML.
This flexibility is part of what has fueled the success and popularity of the Web. Not only do the Web
protocols allow more interactive, multimedia presentations of information, but the typical Web
browser can also offer its user access to other Internet resources, making a Web browser perhaps a
user's most valuable Internet application.
Unlike any other Internet service or protocol, the World Wide Web is based on a concept of
information retrieval called hypertext. In a hypertext document, certain words within the text are
marked as links to other areas of the current document or to other documents (see fig. 2.2). The basic
Windows help engine (and many other online help programs) uses this same hypertext concept to
distribute information.
As you can see in the figure, links can be text or graphics. The user moves to a related area by moving
his or her mouse pointer to the link and clicking once with the mouse button. This generally causes the
current Web document to be erased from the browser's window, and a new document is loaded in its
place.
On the World Wide Web, this synergy can be taken to an extreme. For instance, you might use
hypertext to define a word within a sentence. If I see the following example on a Web page:
The majority of dinosaurs found in this region were herbivores, and surprisingly
docile.
then I can assume that the word herbivores is a hypertext link. That link might take me to a definition
of the word herbivore that this particular author has provided for his readers. This link might also take
me to a completely different Web site, written by another person or group altogether. It might take me
to a recent university study about herbivores in general, for instance, or a drawing of a plant-eating
dinosaur done by a ten-year-old student in Australia.
For just a moment, imagine you're reading a hypertext document instead of a printed page.
If, for instance you were reading a Web page about my personal hobbies, you'd find that one of the
things that interests me most is private airplanes. Clicking that link might take you to a new Web site
dedicated to the discussion of personal aircraft, including a link to Cessna Aircraft's Web site. Once
there, you could read about Cessna's particular offerings, prices, and perhaps a testimonial offered by
a recent satisfied customer. Clicking this link whisks you away to that customer's personal Web site,
where you read his accolades for Cessna, and then notice he's a professor at Yale, and has provided a
link for more information. Clicking the Yale link takes you to the university's Web site, where you can
see different sorts of information about registration, classes, research projects, alumni, faculty, and
other interesting tidbits.
This offers important implications for HTML writers. For one, you've got to take into consideration
this particular style of presenting information. Also, building a good Web site often means being aware
of other offerings on the Web, and creating links to other people's pages that coincide with or expand
upon the information you're presenting.
The World Wide Web is composed of millions of Web pages, each of which is served to a browser
(when requested) one page at a time. A Web page is generally a single HTML document, which might
include text, graphics, sound files, and hypertext links. Each HTML document you create is a single
Web page, regardless of the length of the document or the amount of information included.
The Web page in figure 2.3, for example, contains more information than can be shown on the screen
at one time, but scrolling down the page (by clicking the scroll bar to the right of the browser window)
reveals the rest of that particular Web document-note, though, that scrolling doesn't present you with a
new Web page.
Web site organization is an important consideration for any HTML designer, including those designing
and building corporate Web sites. The typical corporate Web site needs to offer a number of different
types of information, each of which might merit its own Web page or pages.
The typical corporate Web site will start with an index page that quickly introduces users to the
information the site has to offer. Perhaps index is a misnomer, as this page will usually act as a sort of
table of contents for the Web site (see fig. 2.4).
The rest of the pages within a hypothetical corporate Web site will be accessed from a similar index
page, allowing users to move directly to the information they want. If users are interested in getting
phone numbers and addresses for a company, for instance, they might click a link that takes them to an
About the Company page. If they're interested in the company's products, they'd click another link that
would take them to a product demo page.
By organizing the site in this way, the designer makes sure that users can get to every Web page that's
part of the site, while allowing them to go directly to the pages that interest them most.
Now, this really isn't much different from the hypertext links we talked about in the previous section-
the only difference is that hypermedia links point to files other than HTML documents. For instance, a
hypermedia link might point to an audio file, a QuickTime movie file, or a graphic file such as a GIF-
or JPEG-format graphic (see fig. 2.6).
Tip
A hypermedia link can be identified by the fact that the associated file has
something other than an .HTM or .HTML extension.
Because of the flexibility of the Web protocol, these files can be sent by a Web server just as easily as
can an HTML document. All you need to do is create the link to a multimedia file. When users click
that link, the multimedia file will be sent over the Web to their browser programs.
Helper Applications
Once the multimedia file is received by the user's Web browser, it's up to the browser to decide how to
display or use that multimedia file. Some browsers have certain abilities built in-especially the basics,
such as displaying graphics files or plain ASCII text files. At other times, browsers will employ the
services of a helper application.
Most of these helper applications will be add-on programs that are available as commercial or
shareware applications. The browser will generally need to be configured to recognize particular types
of multimedia files, which, in turn, will cause the browser to load the appropriate helper application.
Once loaded, the downloaded multimedia file will be fed to the helper applications, which can then
play or display the multimedia file.
Although it seems that multimedia formats are constantly being added and improved for the Web,
some of the more common types of multimedia files are listed in Table 2.1 with their associated file
extensions. This list isn't exhaustive, but it should give you an idea of the types of files that can be
distributed on the Web.
Not all of these different file formats necessarily require a special helper application. Many sound
helpers will play the majority of different sound files, for instance, and some graphics programs can
handle multiple file types. For the most part, you will need different helper applications for the various
video, animation, and formatted text file types.
Aside from being hypertext-based and capable of transferring a number of multimedia file formats, the
Web is unique in its ability to access other Internet services. Being the youngest of the Internet
services, the Web can access all of its older siblings, including Internet e-mail, UseNet newsgroups,
Gopher servers, and FTP servers. Before we can access these services, though, we need to know what
they do and how their addressing schemes work.
Internet E-mail
Internet e-mail is designed for the transmission of ASCII text messages from one Internet user to
another, specified user. Like mail delivered by the U.S. Post Office, Internet e-mail allows you to
address your messages to a particular person. When sent, it eventually arrives in that person's e-mail
box (generally an Internet-connected computer where he or she has an account) and your recipient can
read, forward, or reply to the message.
username@host.sub-domain.domain.first-level domain
where username is the name of the account with the computer, host is the name of the computer that
provides the Internet account, sub-domain is an optional internal designation, domain is the name
An example of a simple e-mail address (mine) is tstauffer@aol.com, where tstauffer is the username,
aol is the domain, and com is the first-level-domain. com is the three-letter code representing a
commercial entity. This e-mail address describes my account on the America Online service, which is
a commercial Internet site. (See Table 2.2 for some of the more common first-level domain names.)
You may have also noticed that my address doesn't include a host name or a sub-domain. For this
particular address, it is unnecessary because America Online handles all incoming Internet e-mail
through a gateway. Once it receives the e-mail, it may indeed send it to another computer within its
online service, but this is an internal operation that doesn't require a specified host in the Internet
address.
Consider todd@lechery.isc.tamu.edu. This is an address I had a few years ago when I worked at
Texas A&M University. (I no longer receive e-mail at this address.) Notice how it uses all of the
possible parts of an Internet address. todd is the username, lechery is a host computer (in this case, an
actual, physical computer named "lechery"), isc is a sub-domain name that represents the computers in
the Institute for Scientific Computation, tamu is the domain name for all Internet-connected computers
at Texas A&M University, and edu is the three-letter code for educational, which is the type of
organization that Texas A&M is considered to be on the Internet.
UseNet Newsgroups
The next Internet service we'll talk about is UseNet newsgroups. These are the discussion groups on
the Internet, where people gather to post messages and replies on thousands of topics ranging from
computing to popular entertainers, sports, dating, politics, and classified advertising. UseNet is a very
popular Internet service, and most Web browsers have some built-in ability to read UseNet discussion
groups.
Note
Although you'll hear the word "news" a lot when you talk about UseNet, there
isn't an overwhelming number of newsgroups that offer the kind of news you
expect from a newspaper or CNN. In general, UseNet is comprised of discussion
groups like the forums on CompuServe or the message areas on America Online.
Like Internet e-mail, UseNet discussion groups have their own system of organization to help you find
things. This system uses ideas and syntax that are similar to e-mail addresses, but you'll notice that
UseNet doesn't require that you find specific hosts and servers on the Internet-just a particular group.
UseNet newsgroup names use the following format:
first-level name.second-level.third.forth...
The first-level name indicates the type of UseNet group this is, the second narrows the subject a bit,
and the address continues on until it more or less completely describes the group. For instance, the
following are both examples of UseNet newsgroup addresses:
co.general
comp.sys.ibm.pc.misc
The first-level name co means this is a local UseNet group for the Colorado area, and general shows
that it's for discussion of general topics. comp is a common first-level name that suggests this is an
internationally available newsgroup about some sort of computing issue (see Table 2.3). The other
levels of the name tell you more about the group.
Gopher has been described as the poor man's Web, and it's definitely true that Gopher is a precursor to
some of the Web's capabilities. Gopher is a system of menu items that link sites around the world for
the purpose of information retrieval. This isn't a hypertext system like the Web, but it is similar to the
Web in that it's designed for document retrieval.
While Gopher can only offer access to text files and allow you to download files using the FTP
protocol, it is still used occasionally by academic, government, and similar sites. Fortunately, your
Web browser can easily offer Gopher access too, so there's no need to have a separate application.
WAIS, or Wide Area Information Servers, are basically database servers that allow you to search
databases that are attached to Gopher menus. Library databases, academic phonebooks, and similar
information are kept in WAIS systems.
Gopher and WAIS both generally require that you have the exact address of the Gopher server
available to you. These addresses are in the following form:
host.sub-domain.domain.first-level domain
This works essentially like an e-mail address without a username. All the Gopher application needs to
know is the exact Internet location of the Gopher server computer you'd like to talk to. An example
might be marvel.loc.gov. This takes you to a Gopher menu for the Library of Congress.
FTP
The File Transfer Protocol (FTP) is the Internet service that allows computers to transfer binary files
(programs and documents) across the Internet. This is the uploading/downloading protocol that you
might use to obtain copies of shareware or freeware programs, or that might be useful for downloading
new software drivers from a particular computer hardware company.
host.sub-domain.domain.first-level domain
Like Gopher addresses, an FTP address is simply the Internet address of a particular host computer. In
fact, the same host address can be used to serve you both Gopher documents and FTP file directories,
based on the type of protocol your access software requests. The following example is the FTP address
for downloading support and driver files for Apple Macintosh computers and Apple-created Mac and
Windows software:
ftp.support.apple.com
In most cases, FTP connections also require some sort of login procedure, which means you'll need a
username and password from the system administrator to gain access. The majority of public FTP
sites, however, are anonymous sites, which allow anyone access to their files. For these sites, the
username is generally anonymous, and you're asked to enter your e-mail address for the system's
password.
Note
Many Web browsers can access only anonymous FTP sites. You may still need a
dedicated FTP program to access FTP sites that require an account username and
password.
Summary
The World Wide Web is the youngest and most unique of the Internet services. Its protocols allow it to
transmit both text and multimedia file formats to users, while also enabling Web browsers to access
other Internet services. The Web is based on a concept called hypertext, which means that text within
the paragraphs on a Web page is designed to act as links to other Web pages. There is no hierarchy on
the Web, which is only loosely organized by this system of links.
Other services that can be accessed via the Web include Gopher, WAIS, UseNet, e-mail, and FTP.
Each of these older Internet services has its own scheme for formulating addresses. Most of these
services require a server computer of some sort to allow Internet applications to access their
information. These server computers have specific addresses on the Web which you need to know in
order to contact them.
Review Questions
Review Exercises
1. If you have an Internet account or an account with an online service, use your e-mail address to
determine your service's domain name and first-level domain.
2. If you have an FTP application, see if your ISP offers an FTP site. Try the address:
ftp.ispdomain.first-level domain. An example might be ftp.service.net.
3. Using your Web browser, attempt to connect to a Gopher address like marvel.loc.gov. What
happens?
Chapter 3
How Web Browsers Work
HTML codes are written specifically for display in browser applications designed for the World Wide
Web. Unlike some other document formats or specifications, this is the only application for HTML
coding. So it's important to get to know these browsers.
In this chapter, you'll be learning about some popular Web browser applications, how Web browsers
interact with Web servers, and how browsers interact with the other Internet services that are available
to them.
All Web browsers are capable of certain basic tasks, like finding and loading new Web pages, and
displaying them following HTML standards and conventions. There's enough freedom in HTML and
the Web standards in general, though, that each Web browser ends up being slightly unique.
As you look at these browsers, I'd like to make one point clear: although most of them display HTML
documents in a particular way, each browser application actually has quirks or features that you should
keep in mind while you're creating your documents.
Note
This book cannot provide an exhaustive survey of the Web browsers available. It
is fair to say that I'm covering about 90 percent of the current market, but you
should recognize that there are other browsers being used to access HTML pages.
NCSA Mosaic
Originally released by the National Center for Supercomputing Applications (NCSA) in 1993, Mosaic
was the first widely available graphical browser for Web users (see fig. 3.1). It is currently written for
Windows, Windows 95, Macintosh, and various UNIX platforms. It is also the basis of a number of
other browsers on the market-most notably those created and licensed by SpyGlass Corp.
Although definitely in widespread use, the Mosaic family of browsers is nowhere near the most
popular of Web browsers, losing by a significant share of the market to Netscape Navigator. Mosaic
has its merits, though, especially as a straight HTML standards-based Web browser known for being
relatively well-programmed and effective.
One of the most compelling reasons to use NCSA Mosaic might just be that some versions are free to
academic and nonprofit organizations and individuals. It can be downloaded from
http://www.ncsa.uiuc.edu/SDG/Software/SDGSoftDir.html or by FTP at ftp://ftp.ncsa.uiuc.edu/.
Netscape Navigator
Another reason for Netscape's popularity is its ability to accept plug-ins, or helper applications, that
actually extend the abilities of the Netscape Navigator browser window. Netscape users who have the
Macromedia Shockwave plug-in, for instance, can view Macromedia presentation files that are
embedded within HTML documents in Navigator's window (instead of loading a separate helper
application).
Netscape is also available for Windows, Mac, and UNIX users and is available free to certain
qualifying (nonprofit and academic) users (see fig. 3.2). It can be downloaded on the Web from
http://home.netscape.com/comprod/mirror/client_download.html or by FTP at ftp.netscape.com.
When introduced, Netscape's main advantages were speed and the ability to display more graphics
formats than Mosaic. Since that time, however, Netscape has introduced security features and other
technologies (like a built-in e-mail program and built-in UseNet newsreader) that continue to set it
apart from other browsers.
Another advantage is the support of Java applets and JavaScript authoring within Netscape itself.
Again, Java applets can be embedded in the Netscape browser window, allowing the user access to
truly dynamic pages that can be an interface for anything from simple games to stock quotes to bank-
by-computer information. JavaScript gives Web designers programmatic control over their pages,
allowing them to check HTML form entries, load different pages based on user input, and much more.
Perhaps most significant to HTML writers, however, is yet another addition that Netscape offers
beyond Mosaic-Netscape HTML extensions. These are extra HTML-like elements that Netscape can
recognize in Web pages. Although a good deal of debate has raged about whether or not this is
ultimately a good thing for the Web (see sidebar), it remains a fact that a Web site can be designed in
such a way that although most browsers can display the page's basic text and graphics, it is best viewed
in Netscape Navigator.
Why is this? Netscape adds many HTML elements that offer more control over the layout of a page
than the HTML standard allows. This includes such features as centering text and graphics, wrapping
text around figures, and adding tables to Web pages. These elements are not found in HTML 2.0,
although their popularity on the Web has caused many of them to be incorporated into HTML 3.0 level
standards.
Recently released for free to the general public is the Internet Explorer, a Web browser created by
Microsoft Corp (see fig. 3.3). Loosely based on the Mosaic technology, Internet Explorer is a
reasonably well-featured browser with decent speed for modem users. Microsoft's browser is available
for Windows 95, Windows 3.1, and Macintosh platforms. It can be found on the Web at
http://www.microsoft.com/IE/ or by FTP at ftp.microsoft.com.
Like Netscape, Internet Explorer also incorporates elements that are not compliant with the generally
accepted HTML standard. Again, these codes are geared more toward page layout than is the HTML
standard. More and more often, sites on the Web are recommending that you use Internet Explorer to
view the site because it uses the nonstandard HTML elements recognized by Internet Explorer.
Lynx
Lynx and similar browsers are a little different from the others discussed so far, because they lack the
ability to display graphics. It may be surprising that people still rely on text-based browsers to access
the Web, but it remains true that not everyone has a high-speed connection to the Internet. In fact,
many users don't even have a graphical operating system (such as Windows, Mac OS, or OS/2) for
their computer.
Lynx was originally written for the UNIX platform. In fact, it is the browser used by most service
providers for text-based accounts. There is also an MS-DOS version that offers users browsing
capabilities in a text-only format (see fig. 3.4).
Special considerations must go into your HTML documents if they're going to support text-based
browsers like Lynx. Fortunately, as you'll see in the HTML formatting chapters, the HTML 2.0 and 3.0
standards are heavily in favor of text-based browsers-in the spirit of not leaving anyone out.
Inevitably, that will indeed be the case-but a good HTML designer works to minimize that possibility.
Tip
Many considerate Web designers go so far as to create two or more versions of
their Web site-one for graphical browsers, and one that offers only text.
Now that you've looked at the various different Web browsers that might be accessing your Web site,
let's talk about something they all have in common: the use of Uniform Resource Locators (URLs).
What's an URL? If you remember our discussion from the last chapter, you may recall that I mentioned
that most Internet services have "addresses" for accessing information within that service.
Tip
Not everyone follows this convention, but this book is written in such a way that
it will be easier to read if you pronounce "URL" as you would the name "Earl."
Each of these addresses is a bit different. For instance, you would send an e-mail message to my
America Online account using tstauffer@aol.com in an e-mail application.
To acccess the AOL public FTP site, on the other hand, you would enter ftp.aol.com in the FTP
application you are using.
The World Wide Web also has its own addressing scheme, but it's slightly more advanced than the
schemes of its predecessors. Not only is the Web newer, but its addresses have to be more
sophisticated because of the Web's unique ability to access all of the different Internet services.
URLs are these special addresses. They follow a format like this:
protocol://host.domain.first-level domain/path/filename.ext
or
protocol:host.domain.first-level domain
Let's look at that address carefully. According to the format for an URL, then, http:// would be the
protocol, www is the host you're accessing, microsoft is the domain, and com is the first-level domain
type for this system. That's followed by / to suggest that a path statement is coming next.
Note
Those of you familiar with DOS, Windows, or UNIX will probably recognize
path statements right away. Mac OS users and others simply need to realize that a
path statement offers a "path" to a specific file on the server computer's hard
drive. A Web browser needs to know in exactly which directories and
subdirectories (folders and subfolders) a file can be found, so a path statement is a
standard part of any URL.
There are two basic advantages of the URL. First, it allows you to explicitly indicate the type of
Internet service involved. HTTP, for instance, indicates the HyperText Transfer Protocol-the basic
protocol for transferring Web documents. You'll look at this part of the URL in a moment.
Secondly, the URL system of addressing makes every single document, program, and file on the
Internet a separately addressable entity. Why is this useful?
For this example, all you need to do is load your Web browser (whichever you happen to use) and find
the text box or similar interface element that allows you to enter an URL manually to access Web
pages (see fig. 3.5). The point of this example is to show the benefits of using URLs for the Web. With
Gopher and FTP, you really only need to know a host address. But, on the Web, knowing just the host
address often isn't enough.
Once you've located the appropriate entry box, enter www.mcp.com. Depending on the browser you're
using, you'll more than likely need to hit the Enter or Return key after typing this address.
What happens then depends on your Web browser. Some browsers will give an error, which isn't
exactly perfect for this example, but it does prove the point that you need more than just a server
address to get around on the Web. Others will take you directly to the Macmillan Computer Publishing
Web site.
Tip
If your browser gives you an error, enter http://www.mcp.com. Some browsers
require at least a partial URL. Others guess the protocol from the type of server
address entered.
Notice that www.mcp.com follows the addressing conventions established for Internet services like
FTP and Gopher. The problem is that, if the Web used this method for addresses, you'd have to begin
at the first page of the Web site every time you wanted to access one of the hundreds of pages available
from Macmillan.
To get around that, an URL provides your Web browser with more information.
You've already looked at Internet addresses such as www.mcp.com in depth, and you should be
familiar with the concept of a path statement. That just leaves one part of an URL that's new to you:
the protocol.
I've already mentioned that HTTP is the protocol most often used by Web browsers to access HTML
pages. Table 3.1 shows some of the other protocols that can be part of an URL.
Protocol Accesses…
http:// HTML documents
https:// Some "secure" HTML documents
file:// HTML documents on your hard drive
ftp:// FTP sites and files
gopher:// Gopher menus and documents
news:// UseNet newsgroups on a particular news server
news: UseNet newsgroups
mailto: E-mail messages
telnet: Remote Telnet (login) session
By entering one of these protocols, followed by an Internet server address and a path statement, you
can access nearly any document, directory, file, or program available on the Internet or on your own
hard drive.
Note
The mailto:, news:, and telnet: protocols have slightly different requirements
to create an URL. mailto: is followed by a simple e-mail address, news: is
followed by just the newsgroup name, and telnet: is followed by just a server
address. Also notice that file:// is often slightly different for different browsers.
Over time, applications designed to access non-Web Internet services (like FTP or Gopher programs)
will begin to use the URL system more and more. For now though, as a rule, basically only Web
browsers use URLs.
This should result in a listing of the subdirectory demos located on the FTP server ftp.cdrom.com.
Notice that you didn't enter a document name, because, if you're using the FTP protocol, the document
or file will be automatically downloaded.
Tip
If your browser tells you that there are too many users presently connected for
you to connect to this FTP site, wait a moment or two, then click your Reload
button or otherwise reload this URL with your browser.
Not all browsers support the mailto: command-let's see if yours does. In your browser's URL window,
type mailto:tstauffer@aol.com and hit Enter or Return if necessary.
If your browser supports the mailto: protocol command, you should be presented with a new window,
complete with my e-mail address in the Mail To field (see fig. 3.6).
When you enter an URL in the URL field on your browser, the browser goes through the following
three basic steps:
Using all of this information, your browser was able to access the variety of Internet services discussed
previously in Table 3.1 and in the subsequent example. But what does this have to do with HTML
design? Just about everything.
In HTML, a hypertext link is simply a clickable URL. Every time you create a link in a Web
document, you assign an URL to that link. When that link is clicked by a user, the URL is fed to the
browser, which then goes through the procedure outlined above to try and retrieve it.
If you've used your Web browser much, then you've watched this happen countless times, even if you
didn't realize it. If you're using Netscape, Mosaic, or a similar browser, start by pointing your mouse
pointer at just about any link you can find. You may notice that when your mouse pointer is touching
the link, an URL appears in the status bar-probably at the bottom of the page (see fig. 3.7).
That's the URL associated with the link to which you're pointing. Clicking that link will cause the
browser to accept that URL as its next command, in much the same way that you manually entered
URLs in the earlier example. To see it happen, click the link once. Now check the URL field that you
Part of the magic of the HTTP protocol is that it is fairly unlimited (by Internet standards) in the sort of
files that it can send and receive. For instance, like Internet e-mail, much of what is sent on the Web
(via the HTTP protocol) is ASCII text. But, unlike Internet e-mail, HTTP isn't limited to ASCII text.
Note
There are two different types of files that can be sent over various Internet
services. These are ASCII text files (plain text) and binary files. Binary files are
any documents created by applications (such as word processing or graphics
applications) or even the applications themselves. It's easiest to think of binary
files as anything that isn't an ASCII file.
In fact, HTTP can send both of the major types of files-ASCII and binary-using the same protocol.
This means that both plain text files (such as UseNet messages and HTML documents) and binaries
(such as downloadable programs or graphics files) can be sent via the Web without any major effort on
the part of the user. In certain cases, the HTML author will have to make a distinction (for instance, as
to whether or not a graphics file should be displayed or downloaded to the user's machine), but, for the
most part, HTTP figures this stuff out by itself.
How exactly does it figure these things out? Usually by a combination of the protocol selected and the
extension to the filename in question. For instance, a file called INDEX.HTML that's accessed using an
URL that starts with the http:// protocol will be displayed in a browser as an HTML file, complete
with formatting and hypertext links.
The same file, however, if it is renamed to be INDEX.TXT, even if it's loaded with an http:// protocol
URL, will be displayed in the browser as a simple ASCII file, just as if it were being displayed in
WordPad, SimpleText, or Emacs. Why is this? Because the extension tells the Web browser how to
display the file.
You may recall from Chapter 1 that much of an HTML document is "text" (the rest being HTML
codes). In fact, all of an HTML document is ASCII text, as is demonstrated in figure 3.9. It is only the
extension .HTML (or .HTM on DOS-based Web servers) that tells a Web browser that it needs to
interpret some of the text as HTML commands within a particular ASCII text document.
Tip
Because HTML documents are ASCII text, it's possible to create them in simple
text editor programs. A Microsoft Word document, on the other hand, is not
ASCII text-it's saved in a binary format. So, if you use a word processor to create
HTML documents, remember to use the Save As command to save the HTML
page in an ASCII format.
To the HTML designer, this means two things. First of all, you should recognize that your HTML
pages can offer just about any other type of file for transport across the Web. If you want to send
graphics, games, WordPerfect documents, or just about anything else, just put a hypertext link to that
file on your Web page.
Second, you need to remember that the most important part of a filename is its extension. If you fail to
put the correct extension on a filename, your user's browser won't know what to do with it. If you're
trying to display a graphic on your Web page, for instance, but put a .TXT extension on it, it won't
display.
Everything is Downloaded
There's one other thing you should realize about the Web and Web browsers before you begin to
develop Web pages. Very simply, everything you view in a Web browser has to be downloaded from
the Web site first. What do I mean by this?
Whenever you enter an URL or click a hypertext link, the HTML document (or binary file) that you're
accessing is sent, in its entirety, from the Web server computer to your computer's hard drive. That's
why, for instance, Web pages with a lot of graphics files take longer to display than Web pages with
just text.
For the Web user, this is both good and bad. It's good because once a page is downloaded, it can be
placed in the cache, so that the next time you access the page, it will take much less time to display. It's
also good because anything that's currently displayed in your browser window, including the HTML
document and any graphics files, can be instantly renamed and filed on your hard drive for your
personal use.
Tip
If you use Netscape Navigator, click and hold the mouse button (on a Mac) or
click the right mouse button (in Win95) while pointing to a Web page graphic.
Notice that, after a few seconds, you can rename that graphic and save it to your
hard drive.
The bad side of downloading, though, is that every graphic and all of the text you include in an HTML
page has to be transmitted over the Internet to your user's computer. If your user is accessing the Web
over a modem, then downloading and displaying your page can take a long time-especially if your
Web page includes a lot of graphics. This means that HTML designers have to be constantly aware of
the size of their HTML documents and their Web page graphics in order to avoid causing their users
unnecessary irritation and wasted time.
Note
It takes 15 to 30 seconds (on average) for a 25 kilobyte graphic to be transmitted
over a 28.8 kbps modem connection. So a 100 kilobyte Web page could take
around two minutes to transfer-the length of four television commercials.
Summary
There are a number of popular Web browser applications that Web designers should take into
consideration when designing their Web pages. Each browser displays HTML codes in slightly
different ways and some-like Netscape and MS Internet Explorer-even add their own HTML-style
commands.
The Web uses a particular style of Internet address, called an URL, which allows it to address
individually any document on the Internet. This offers an advantage over other Internet address
schemes because it specifies the Internet service protocols desired and points directly at documents.
It's important for the Web designer to remember that everything on a Web page is downloaded,
including text and graphics. The larger the graphics on a Web page, the longer it will take to display.
This is also an advantage, though, since pages can be cached for future use.
Review Questions
1. Which browser was the first graphical browser on the market? Which is currently most
popular?
2. Most Netscape HTML extensions are designed to help with what aspect of Web pages?
3. What makes the Lynx browser different from the others discussed?
4. Is the following an URL, a server address, or a path statement?
www.mcp.com
5. What makes the mailto: command different from a standard URL?
6. What ASCII character comes between each folder or directory in a path statement?
7. If I entered the following in my browser's URL field (and hit Return, if necessary), would it
download a file?
http://ftp.cdrom.com/pub/win95/games/four.zip
8. True or false. Graphics displayed on a Web page are downloaded to the user's computer, which
is why they often take extra time to display.
9. Are the following files ASCII files or binary files? A CorelDRAW! picture, an HTML page, a
Microsoft Word document, and a WordPad document.
Review Exercises
1. Use your current Web browser to access one of the FTP sites mentioned in the "Web Browser
Applications" section of this chapter. Notice how browsers handle FTP connections.
2. Use an ftp:// URL to download one of those other Web browsers (or another file) directly.
Hint: you'll need to figure out the path to the file first.
3. If your ISP allows it, use a modem communications program to dial up your account, and then
use Lynx or a similar text browser through your ISP's connection. Notice how different the
Web is without graphics and a mouse!
Chapter 4
Creating Basic HTML Documents
It is important to realize that an HTML document must be built on a very specific framework. This
framework, in its simplest form, consists of three sets of matched container tags.
A tag is a simple markup element, and always takes the form <TAG>. A container is a pair of HTML
tags of the form <TAG> </TAG>. You can think of the <TAG> element as turning something on, while the
</TAG> turns that same thing off. For example, consider this line of HTML:
The first HTML tag, <I>, turns on italics. The second tag, </I>, turns them off. When displayed on-
screen, this line of text would look like this: This is in Italics. But this isn't. The tags themselves don't
appear on-screen. They just tell the browser program how to display the elements they contain.
The simplest possible HTML document is given in Listing 4.1. The entire document is enclosed in the
<HTML></HTML> container tags. The first part of the document is encapsulated in the <HEAD></HEAD>
container, which itself contains a <TITLE></TITLE> container. Finally, the body of the page is
contained in a <BODY></BODY> container.
The most fundamental of all the tags used to create an HTML document is, not surprisingly, the
<HTML> tag. This tag should be the first item in your document and the corresponding end tag,
</HTML>, should be the last. Together, these tags indicate that the material contained between them
represents a single HTML document (refer to Listing 4.1). This is important because an HTML
document is a plain text ASCII file. Without these tags, a browser or other program isn't able to
identify the document format and interpret it correctly.
NOTE: While most of the recent browsers properly interpret a document that is not contained within
the <HTML> start and </HTML> end tags, it is still very important to use them. Many of the new uses for
HTML documents, such as e-mail and Usenet postings, do not necessarily involve browsers, and the
other programs are more likely to interpret an ASCII document as plain text without the hint that the
<HTML> tag provides.
The </HTML> end tag is just as important as the start tag. It is becoming possible to include HTML
documents within e-mail messages and news postings. Without the </HTML>, the viewer does not know
when to stop interpreting the text as HTML code.
The document head container is not a required element, but a proper head can greatly increase the
usefulness of a document. The purpose of the head is to provide information to the application that is
interpreting the document. With the exception of the TITLE element, the elements within the head
element are not seen by the reader of the document.
• Provide a method for sending special messages to a specific browser or other viewer.
Listing 4.2 shows an example of an HTML document with a proper HEAD element.
The HEAD element is opened by the start tag, <HEAD>. This tag normally should immediately follow the
<HTML> start tag. The end tag, </HEAD>, is used to close the element. The rest of the head element tags
are located within this container.
The TITLE element is the only required element of the heading. It is used to give your document a
name. This title is generally displayed in the title bar of the browser. The TITLE should not be confused
with the file name of the document; instead, it is a text string that is completely independent of the
name and location of the file. This makes it highly useful, the file name is generally constrained by the
operating system of the computer that the file is located on.
The TITLE element is delimited by a <TITLE> start tag and a </TITLE> end tag. The actual title is
located between these tags. Do not enclose the title in quotation marks unless you want it to appear
with the quotes. It is most common for the TITLE element to be all on one line.
The title text is a string of unlimited length that can include any text except for the few special
characters that are restricted in HTML. In practice, it is a good idea to keep the length of the title fairly
short so that it fits on the title bar. Another thought to keep in mind when making up a title is that
many browsers use the title as the caption for the icon when the browser is minimized. Try to make the
first few characters particularly meaningful.
NOTE: The TITLE is normally used as the default name when a user creates a bookmark or Favorites
link to the document. To make this default as useful as possible, avoid having a title like Home Page or
Index. Entries like this are nearly useless in a bookmark list.
Listing 4.3 is an example of a document TITLE. Figure 4.1 shows how Microsoft Internet Explorer
uses the document TITLE as the title of the browser window.
FIG. 4.1
Titles provide your readers with a way to identify your documents.
This might sound unlikely, but consider that a long document might be downloaded to a user's machine
so that he might read it when offline. Any links, such as a bibliography, would be unusable when the
local copy was viewed. If the user wanted to link to other documents or images, he would first need to
reopen the first document on the computer where it normally resides.
Fortunately, the designers of HTML anticipated this problem and have added two elements, BASE and
LINK, that can be placed in a document head to help keep a document relationship straight.
NOTE: If you're just learning HTML, you might want to skim through this section. It isn't necessary to
use the BASE and LINK elements until you start developing complicated documents that require many
pages.
The BASE Element The BASE element is used to specify the full original URL of the document. This
allows relative links to work, even if a document has been moved to another directory (or even to
another machine!). In this way, a BASE element allows the viewing software to find a document link,
even when directed from a parent in a different location. The BASE element has a single required
attribute which provides the full URL of the document: HREF. Listing 4.5 provides an example of how
the <BASE> tag is used.
Notice that the BASE element directs the viewer software where to look for the files. Even if a person
has downloaded the file to his local machine, the little images for News and Mags can still be found,
assuming that the reader's machine has access to the Internet.
The LINK Element If the BASE element allows a browser to locate a document, there still exists the
question of what the relationship between two documents might be. This becomes even more
important as the complexity of your HTML document increases. To connect documents together
logically, HTML includes the LINK element. The LINK element indicates the relationship between the
document that contains the <LINK> tag and another document (or other object). It consists of an URL
that points to the reference object and an attribute that serves as a description of the relationship. In
other words, if a parent HTML document provided a link to the current child HTML document, the
current document could provide a <LINK> tag back to the parent to indicate that relationship. A
document can contain as many LINK elements as needed to describe all of the relationships. Table 4.1
lists all of the attributes and their functions.
There are many different relationships possible, and the list is not well defined in the HTML
specification. The most common REV relationship is "made", which provides a link for e-mailing a
document's author, as shown in the following example:
Some examples of relationships to other HTML documents that can be indicated with the REL attribute
are "bookmark", "copyright", "glossary", "help", "home", "index", and "toc".
There are also two relationships that are most commonly used in ordered documents: "next" and
"previous". These are particularly useful relationships. Listing 4.6 shows the HEAD element for a
document that is a chapter in an online manual.
Although it might seem that the elements that can be placed in a document heading already cover
every imaginable possibility, the truth is that they barely begin to scratch the surface. Because the
procedure for the development and approval of a new HTML specification is rather slow, the
companies that produce browser software often create several releases in the time between
specification versions. To provide additional functionality, one final element is provided for the
heading.
The META element allows a document author to define information that is outside of HTML. This meta-
information can be used by the browser software to perform activities that are not yet supported by the
official HTML specification. As a rule, META elements are not needed for a basic HTML document, but
you should keep these elements in mind as you gain experience and as your pages become more
sophisticated.
Figure 4.2 is an example of how the META element can be used to have the browser perform an action.
This is interpreted by Netscape Navigator and Microsoft Internet Explorer as the instruction to wait 60
seconds and then load a new document. This kind of instruction is often used when a document is
can be used to have the browser reload the page every 60 seconds. This is useful for a page that has
frequently updated information, such as a stock price ticker.
NOTE: Both of these techniques are known as client pull because the client, your browser, requests
the new document from the server. These are advanced techniques, and you don't need to use them
except in circumstances when data is changing or the page needs to be reloaded.
Finally, the most popular use of a META element at the present is to use the Keywords property. Many
search engines preferentially use the words defined in this element to index the document. This can be
used to provide additional keys to an index that might not actually appear in the document verbatim.
Listing 4.7 shows how this works.
When designing a document that will be indexed by a search engine, it is also a good idea to use the
Description property. Most indexes use this description for your page, if it is present. If no
description is present, the index uses the first text available on the page, which can be confusing to
some using the index.
For more on the topic of search engines, see Chapter 40, "Listing Your Web Site in the Search Tools."
NOTE: The Keywords and Description properties are good first choices when you start to use META
elements. Both of them are easy to understand, and they add a lot of value to your documents.
The syntax for the META element includes the attributes shown in Table 4.2. Much like the relationships
in the LINK element, the properties of the META element are not clearly defined in the current version of
the HTML specification.
There are two additional elements that can be found in the document heading. The first is the SCRIPT
element and the second is the STYLE element. The former is used to add interactive control scripts to
pages, while the latter adds various styles to page content.
Although the nature of the World Wide Web appears to be changing in the direction of increasing
active content, most people who view your documents will still be interested in your text. This will be
especially true for documents that are created for corporate intranets and for documents that serve as
online manuals and texts. Because of this, whether you are converting existing documents or creating
new ones, you will spend much of your time working in the body.
Before you can fill in your document, you need to lay out a basic working framework. HTML
documents must follow a defined pattern of elements if they are to be interpreted correctly. Rather than
retype the elements that are used in every HTML document, it is a good idea for you to create a
template to use for each of your pages so that you are less likely to leave out an important detail. At the
end of this chapter, we build a template that you can use as a starter. Until then, we'll use the example
presented in Listing 4.8.
This example begins with the <HTML> tag, which, as you have read, is necessary for every HTML
document. Next is the <HEAD> tag, which opens up the heading part of the document. This contains the
TITLE element. We've titled the document "This is an example document." The heading is closed with
the </HEAD> tag. Finally, the <BODY> element follows. This is where you place the bulk of the material
Because HTML is a markup language, the body of your document is turned on with the start tag,
<BODY>. Everything that follows this tag is interpreted according to a strict set of rules that tell the
browser about the contents. The body element is closed with the end tag, </BODY>.
NOTE: Strictly speaking, it isn't absolutely necessary to use the <BODY> start and end tags; HTML
allows you to skip a tag if it is obvious from the context. (In this case, <BODY> would be implied after
the ending </HEAD> tag, and </BODY> would be implied before the ending </HMTL> tag or the end of
the document.) However, it's still a good idea to use them. Some older browsers and other HTML
programs can become confused without them and may not display the document correctly.
In the preceding basic document, the body text is a single line. In your document, you replace this line
with the main text of your document. Unless you are using a special HTML editor, you must enter your
text using a strict ASCII format. This limits you to a common set of characters that can be interpreted
by computers throughout the world.
NOTE: Most browsers consider all nonblank white space (tabs, end-of-line characters, and so on) as a
single blank. Multiple white spaces are normally condensed to a single blank.
The BODY element supports a large number of attributes. These are all important for determining the
general appearance of your document. Table 4.3 lists these attributes and their functions for your
convenience, but we cover each of them in more detail.
Cascading Style Sheets, which are discussed in Chapter 17, "Applying Cascading Style Sheets," are the
latest and greatest way to adjust a page's colors and other styles. However, there are easy-to-use
<BODY> tag attributes that can also give you elementary control over the colors of your page elements.
NOTE: Because you have no way of knowing which colors have been selected as defaults by the
reader, it is considered good HTML practice to set all of the colors, if you set any. This way, the same
color isn't used for more than one component.
There is no simple rule that can be used to define a well-balanced palette, but remember that your
readers must actually read your document. Try to maintain a high contrast between the text and the
background and don't make the color differences too subtle.
Color Definitions Colors are defined in HTML using a hexadecimal coding system. The system is
based upon the three components--Red, Green, and Blue--which leads to the common name of RGB.
Each of the components is assigned a hexadecimal value between 00 and FF (0 and 255 in decimal
numbers). These three values are then concatenated into a single value that is preceded by a pound sign
(#). An example of such a value is #800080, which is purple. Because few people can visualize colors
based solely on a hexadecimal value, HTML defines 16 standard color names, which are listed along
with their hexadecimal values, in Table 4.4. Yahoo! maintains an extensive list of Web sites which
feature color table information at
http://www.yahoo.com/Computers_and_Internet/Internet/World_Wide_Web/Page_Design_and_
Layout/Color_Information/.
Color Value
Black #000000
Maroon #800000
Green #008000
Olive #808000
Navy #000080
Purple #800080
Teal #008080
Gray #808080
Silver #C0C0C0
Red #FF0000
Lime #00FF00
Yellow #FFFF00
Blue #0000FF
Fuchsia #FF00FF
Aqua #00FFFF
White #FFFFFF
You can use either these color names or their values when defining colors for HTML document
elements. For example, the following lines are equivalent:
<BODY BGCOLOR="#FFFFFF">
<BODY BGCOLOR="WHITE">
The Body Color Attributes The BGCOLOR attribute is used for the document background color. If
your document has a background image, the BGCOLOR should be as close the primary color of the image
as possible. This allows readers who may not be downloading images to see your text clearly. Many
authors make this common mistake, which is particularly bad if the background image is primarily
black and the text color that you selected was white. In this case, the reader of your document is
greeted by the sight of what is apparently a blank page! For example, if you are using a background
graphic that is mostly black, you should also add the BGCOLOR="black" attribute to your page's <BODY>
tag.
The TEXT attribute is the color used for the text in the document. Because most of your text appears in
this color, it should be chosen to provide the reader with sufficient contrast. If you have elected to set
the font, be aware that fonts with fine detail are often easier to read when they are dark against a bright
background.
The LINK attribute is used by the browser for links that have not yet been followed. This color should
be obviously different from the TEXT color, so that readers can identify links.
The VLINK attribute is used to identify links that have already been visited. A common choice for
VLINK is to use a darker version of the LINK color.
The ALINK attribute marks links that are currently active. This is a relatively recent development and is
normally used for documents that have multiple frames. Quite frankly, choose your other colors first;
the reader is least likely to see this color than any of the others. See Chapter 12, "Framing Your Web
Site," for more information about frames.
Having seen all of the things that can be colored in an HTML document, you might wonder if the
results justify the effort. If you are creating a static document--such as a manual or a textbook--you
might be best off to let the reader set the colors that she wishes to use. On the other hand, if your
document is a high-energy page with a lot of graphics, then it is certainly worth the time to find the
right blend of colors.
One popular way to dress up an HTML document is to add a background image. A background image
is a graphics file that is visible under the document text. Using a background can help provide
continuity to a document, or it can also serve to differentiate the various pages.
Most background images are small and are tiled across the viewer window like wallpaper. Images of
textures are particularly popular for this purpose; bricks, marble, and cloth are often seen on HTML
Other types of wallpaper that can make a document look good include a corporate logo or other image.
These should be very subdued, almost monochrome, so as not to interfere with the foreground text or
distract from your document's message. One way to accomplish this is to emboss an existing image
using a graphics program. Chapter 22, "Graphics," discusses some of the tools available for creating
these images. Figure 4.4 is an example of how this can be used.
A background can also be created to watermark a document. This type of background can be used for
an official seal or for a text message such as Draft or Confidential.
Background images look good, but they won't be seen by someone who's turned off the automatic
loading of images. Remember the advice in the BGCOLOR section and set the background color to match
the primary color of the image, so that your page is readable even if the reader doesn't get to see the
background.
NOTE: The BGPROPERTIES attribute is unique to Microsoft Internet Explorer. The only acceptable
value for this attribute is FIXED. If BGPROPERTIES=FIXED, the background image does not scroll with
the text. This is a nice effect with a wallpaper background and is useful if you've created a watermark
background.
It is possible to add comments to your HTML document that aren't seen by a reader. The syntax for
this is to begin your comment with the <!-- tag and to end it with the --> tag. Anything located
between the two tags is not displayed in the browser. This is a convenient way to leave notes for
yourself or others. For example, you can enter a comment when new material is added to a document
that shows the date of the new addition.
CAUTION: Don't assume your comments can't be seen by your readers. Most browsers allow the
source of your document to be viewed directly, including any comments that you have added.
On the other hand, don't try to use comments to "comment out" any HTML elements in production
documents. Some browsers interpret any > as the end of the comment. In any case, the chances of an
older browser becoming confused are pretty good, resulting in the rest of your document being badly
scrambled. If you are going to use comments to cut out HTML elements while you are testing the
document, you should remove them in the final release.
One of the most important elements for your documents is the ADDRESS element. This is where you
identify yourself as the author of the document and (optionally) let people know how they can get in
The ADDRESS element consists of text enclosed by an <ADDRESS> start tag and an </ADDRESS> end tag.
The text within an ADDRESS element is normally displayed in italics.
Listing 4.9 is an example of one such address element, and Figure 4.5 shows how it looks.
NOTE: A very important addition to the address is to indicate the date you created the document and
the date of the last revision. This helps people determine if they have already seen the most up-to-date
version of the document.
Now, let's build a basic document template that you can use with your documents. This template
allows you to start converting some of your existing documents to HTML. In the following chapters,
you will see how to expand upon this template.
Let's begin with the required tags: <HTML>, <HEAD>, </HEAD>, <BODY>, </BODY>, and </HTML>. You
also need to include the TITLE element, as this is a required element in HTML. Finally, put in a
dummy line of text to remind yourself where to put the text. This gives you Listing 4.10.
This would certainly suffice for a basic document, but you can do a lot better without much effort.
First, let's add a simple gray textured background to the document, which changes the <BODY> tag to:
<BODY BACKGROUND="greybg.jpg">
Earlier in the chapter you read that if you add a background image to a document, you should set the
colors so that the reader can see your text. First, set the BGCOLOR attribute to GRAY. This is the closest
match to the background. We'll also set the TEXT to BLACK, and LINK, ALINK, and VLINK to BLUE,
GREEN, and RED, respectively. These additions change the <BODY> tag to
You should have an ADDRESS element for the document, so add the following:
When all of these are added to the first pass of the template, you get Listing 4.11.
Chapter 5
Formatting Text as Paragraphs
Your old English teacher taught you to break your writing up into paragraphs that expressed complete
thoughts, and an HTML document shouldn't be an exception. Unfortunately, line and paragraph breaks
are a little more complicated in HTML than you might expect.
As a markup language, HTML requires that you make no assumptions about your reader's machine.
Your document's readers can set whatever margins and fonts they want to use. This means that text
wrapping must be determined by the viewer software, as it is the only part of the system that knows
about the reader's setup. Line feeds in the original document are ignored by the viewer, which then
reformats the text to fit the context. This means that a document that's perfectly legible in your editor is
badly mashed together in the viewer.
NOTE: Different viewers display the same pages in different ways, depending on their default settings
and user options. In this chapter, we've used examples from different browsers to mix things up a bit.
The proper way to break text into paragraphs is by using paragraph elements. Place a paragraph start
tag, <P>, at the beginning of each new paragraph, and the viewer knows to separate the paragraphs.
Adding a paragraph end tag, </P>, is optional, as it is normally implied by the next start tag that comes
along. Still, adding the </P> tag at the end of a paragraph can help to protect your documents against
viewers that don't precisely follow the HTML standard.
NOTE: Seriously consider using the beginning and ending paragraph tags. As style elements, which
give you more control over the <P> tag, become more prevalent, this syntax becomes more important.
NOTE: In some HTML documents, you see a paragraph start tag, <P>, used repeatedly to create
additional white space. This is not supported in HTML, and most current viewers will ignore all of the
<P> tags after the first one.
The paragraph element has one attribute that is supported by both Netscape Navigator and Microsoft
Internet Explorer. This is the ALIGN attribute. The possible values for the ALIGN attribute and their
functions are listed in Table 5.1. The default value, if the ALIGN attribute is not used, is for left
alignment.
NOTE: The ALIGN attribute can also be used with many other HTML tags to align graphics, table
contents, and other page elements. Its use in these contexts will be discussed in following chapters.
Attribute Function
LEFT Aligns the text with the left margin of the viewer. The right edge is ragged.
CENTER Centers the text between the viewer margins.
RIGHT Aligns the text with the right margin of the viewer. The left edge is ragged.
As you have seen, HTML does all of the formatting at the viewing software rather than at the source.
This has the advantage of device independence. But what do you do if you have a reason to break up a
line of text at a certain point?
Use the line break tag, <BR>, to end a line where you want. This forces the viewer to start a new line,
regardless of the position in the current line. Unlike the paragraph element, the line break does not
double space the text. Because the line break element is not a container, it does not have an end tag.
One reason you might want to force line breaks is to show off your poetic muse, as shown in Listing
5.1.
When this source is viewed in Figure 5.5, you can see how the line break element works.
CAUTION: You might think you can use multiple line breaks to provide extra white space in your
document. Some browsers condense multiple line breaks (multiple <BR> or <P> tags) to a single line
break, however.
You need to be careful when using line breaks; if the line has already wrapped in the viewer, your
break may appear after only a couple of words in the next line. This is particularly the case if the
viewer you test your documents on has wider margins than your reader's viewer. Figure 5.6 shows an
example in which the author saw that the break was occurring in the middle of the quotation, so she
added a <BR>. Unfortunately, when displayed on a screen with different margins, the word "actually"
ends up on a line by itself.
NOTE: This can be very useful for items such as addresses, where an unfortunate line break can cause
unexpected results. Don't overuse the <NOBR> element, however. Text can look very strange when the
natural line breaks have been changed.
TIP: If you think you might need a break inside a <NOBR> element, you can suggest a breaking point
with a <WBR> tag (soft line break). The viewer will only use the <WBR> if it needs it.
So far, your HTML document probably looks a little dull. To make it more interesting, the first thing
you need to do is add a little more structure to it. Web users want to be able to quickly scan a
document to determine whether or not it has the information they are looking for. The way to make
this scanning easier is to break the document up into logical sections, each covering a single topic.
After you have broken up the document, the next step is to add meaningful headers to each section,
enabling your reader to quickly jump to the material of interest.
Adding Headings
Headings in HTML provide an outline of the text that forms the body of the document. As such, they
direct the reader through the document and make your information more interesting and usable. They
are probably the most commonly used formatting tag found in HTML documents.
The heading element is a container and must have a start tag (<H1>) and an end tag (</H1>). HTML
has six levels of headings: H1 (the most important), H2, H3, H4, H5, H6 (the least important). Each of
these levels has its own appearance in the reader's viewer, but you have no direct control over what
that appearance is. This is part of the HTML philosophy: You, as the document writer, have the
responsibility for the content, while the viewer has the responsibility for the appearance. See the
example in Listing 5.2. (See Chapter 17, "Applying Cascading Style Sheets," to learn more about using
style sheets to change text properties for tags such as <H1>.)
NOTE: Although it is not absolutely necessary to use each of the heading levels, as a matter of good
practice you should not skip levels because it may cause problems with automatic document
converters. In particular, as new Web indexes come online, they will be able to search Web documents
and create retrievable outlines. These outlines may be confusing if heading levels are missing.
NOTE: Remember that forgetting to add an end tag definitely messes up the appearance of your
document. Headings are containers and require both start and end tags. Another thing to remember is
that headings also have an implied paragraph break before and after each one. You can't apply a
heading to text in the middle of a paragraph to change the size or font. The result is a paragraph broken
into three separate pieces, with the middle paragraph in a heading format.
The best way to use headings is to consider them the outline for your document. Figure 5.8 shows a
document in which each level of heading represents a new level of detail. Generally, it is good practice
to use a new level whenever you have two to four items of equal importance. If more than four items
are of the same importance under a parent heading, however, try breaking them into two different
parent headings.
Headings can use the ALIGN attribute, just as the <P> tag does. This is important to remember, because
not all viewers show all headings left-aligned. Figure 5.9 shows the use of the ALIGN attribute in a
heading.
Another method for adding divisions to your documents is the use of horizontal lines. These provide a
strong visual break between sections and are especially useful for separating the various parts of your
document. Many viewers use an etched line that presents a crisp look and adds visual depth to the
document.
You can create a horizontal line using the horizontal rule element, <HR>. This tag draws a shaded,
horizontal line across the viewer's display. The <HR> tag is not a container and does not require an end
tag. There is an implied paragraph break before and after a horizontal rule.
Listing 5.3 shows how horizontal rule tags are used, and Figure 5.10 demonstrates their appearance in
the Netscape Navigator viewer.
Attribute Function
ALIGN Can be set to LEFT, CENTER, or RIGHT.
WIDTH Can be entered in pixels or as a percentage of the viewer window width. If a percentage is
desired, add a percent time to the number.
SIZE The height of the ruled line in pixels.
NOSHADE If this attribute is present, the viewer does not use a three-dimensional effect.
COLOR Specifies the color of the ruled line. An RGB hexadecimal value or a standard color name
can be used.
TIP: Documents created using early versions of HTML often used a graphic image to provide a more
colorful and obvious break. Of course, these would not appear in viewers that had image loading
turned off. Even if the viewer were loading images, a color bar was another file that had to be copied
and maintained. The new <HR> attributes allow you much more flexibility in the creation of your
documents at virtually no loss of speed or ease of maintenance.
Is it absolutely necessary to use paragraph and line break elements for formatting text? Well, not
really; HTML provides a container that can hold preformatted text. This is text that gives you, the
author, much more control over how the viewer displays your document. The trade-off for this control
is a loss of flexibility.
The most common and useful preformatting tag is the <PRE> container. Text in a <PRE> container is
basically free-form with line feeds causing the line to break at the beginning of the next clear line. Line
break tags and paragraph tags are also supported. This versatility enables you to create such items as
tables and precise columns of text. Another common use of the <PRE> element is to display large
blocks of computer code (C, C++, and so on) that would otherwise be difficult to read if the browser
reformatted it.
Text in a <PRE> container can use any of the physical or logical text formatting elements. You can use
this feature to create tables that have bold headers or italicized values. However, the use of paragraph-
formatting elements such as <Address> or any of the heading elements is not permitted. Anchor
elements can be included within a <PRE> container.
The biggest drawback to the <PRE> container is that any text within it is displayed in a monospaced
font in the reader's viewer. This tends to make long stretches of preformatted text look clunky and out
of place.
Figure 5.12 shows an example of some preformatted text in an editor. You can use the editor to line up
the columns neatly before adding the character-formatting tags. The result of this document is shown
in Figure 5.13.
TIP: If you are not converting existing documents, the HTML tables are much more attractive than are
those you can create by using the <PRE> element. See Chapter 11, "Formatting Content with Tables,"
for more information on this topic.
CAUTION: Tab characters move the cursor to the next position, which is an integer multiple of eight.
The official HTML specification recommends that tab characters not be used in preformatted text
because they are not supported in the same way by all viewers. Spaces should be used for aligning
columns.
NOTE: There are other preformatted container classes, but these have been declared as obsolete. The
<XMP> and <LISTING> elements give you the capability to create text that is already laid out. There are
NOTE: If you want to show actual HTML code in a preformatted section, or you want to use the < or
> characters, you need to use the < and > entity codes, like this: <PRE>.
The <DIV></DIV> container (DIV stands for division) can be used to enclose and define the alignment
for an entire block of page elements. It supports the ALIGN attribute, so you could use it to align a block
of text and graphics to CENTER, as in this example:
<DIV ALIGN=CENTER>
<H1>This header is centered.</H1>
<IMG SOURCE="somepic.gif"><BR>
So are the images above and this line of text.<BR>
<P ALIGN=RIGHT>But this text is right-aligned.</P>
</DIV
Note that all the elements between the <DIV> and </DIV> tags are aligned according to the definition
given by the <DIV> tag, except for any elements which have their own alignments defined. As is
always the case with the ALIGN attribute, it can assume the values LEFT, CENTER, or RIGHT.
You can also use inline styles with the <DIV> tag to set the style for an entire block of HTML within
your document. This works because of the concept of inheritance. For example, if you want to change
the text color of an entire block of tags to blue, you can put those tags in the DIV container and define a
style for the <DIV> tag that sets the text color to blue. It looks like this:
The DIV tag is also an important part of advanced page layout using Cascading Style Sheets, and will
be discussed in that context in Chapters 17 and 18.
Layout Tips
• Use equal spacing. Try to keep the spacing between elements consistent. That is, make sure the
same amount of space is above and below each of your paragraphs. Readers perceive uneven
spacing as sloppiness on your part.
• Avoid right- and center justification. Don't right or center-justify the main body of text. Right-
and center-justified text is harder to read than left-justified text.
• Don't go overboard with indents. Proper indentation depends on the size of the font you're
using. A larger font requires a deeper indent and vice versa.
• Use <NOBR> with <WBR> to maintain control of line breaks. Sometimes you want to control
exactly where the browser breaks a line if it needs to. <NOBR> turns off line breaks while <WBR>
provides hints to the browser that suggests a spot for a line break if necessary.
• Consider dividing a page that uses <HR>. If you find yourself using rules to divide a Web page
into individual topics, consider splitting that Web page into individual pages so each page
remains focused on a single topic.
• Give plenty of space to artwork. The images and tables in your HTML document should have
enough white space around them so that they're set apart from the text. You don't want them to
appear cramped.
• Use headings to organize your text. Headings give readers a visual road map that helps them
locate the information in which they're interested. Use them liberally.
A Specialized Template
Using what you've learned in this chapter, you can create a more sophisticated template. Now you can
use some of this chapter's features to build a template that can be used for glossaries and related
documents.
The first step is to bring the existing template into your editor. Once you've loaded it, you can make the
appropriate changes to the elements that are already present. These can be seen in Listing 5.5.
Chapter 6
Applying Charcter Formatting
Once you've created your document, much of the hard work is done. The text that you've written is
neatly broken into paragraphs, headings are in place, and the miscellaneous items such as the title and
the author information have been added. At this point you could walk away satisfied, but something
still seems to be missing.
One of the primary things that separates documents created on a word processor from those produced
on a typewriter is the idea of text formatting. Word processors give the author control over how her
text will look. She can chose the font that she likes in the appropriate size, and she can apply one or
more of a myriad of options to the text. In HTML, you have this same capability. Your only real
restrictions involve the importance of viewer independence.
Logical Formatting
One of the ideas behind HTML is that documents should be laid out in a logical and structured manner.
This gives the users of the documents as much flexibility as possible. With this in mind, the designers
of HTML created a number of formatting elements that are labeled according to the purpose they serve
rather than by their appearance. The advantage of this approach is that documents are not limited to a
certain platform. Although they may look different on various platforms, the content and context will
remain the same.
• <CITE> The citation element is used to indicate the citation of a quotation. It can also be used
to indicate the title of a book or article. An italic font is normally used to display citations.
• <CODE> The code element is used to indicate a small amount of computer code. It is generally
reserved for short sections, with longer sections noted by using the <PRE> tag described later.
Code normally appears in a monospaced font.
• <EM> The emphasis element is used to indicate a section of text that the author wants to
identify as significant. Emphasis is generally shown in an italic font.
The actual line reads, "Alas, poor Yorick. I knew him, EM>Horatio</EM>."
• <KBD> The keyboard element is used to indicate a user entry response. A monospaced
typewriter font is normally used to display keyboard text.
• <SAMP> The sample element is used to indicate literal characters. These normally are a few
characters that are intended to be precisely identified. Sample element text normally is shown
in a monospaced font.
• <STRONG> The strong element is used to emphasize a particularly important section of text.
Text using strong emphasis is normally set in a bold font.
• <VAR> The variable element is used to indicate a dummy variable name. Variables are
normally viewed in an italic font.
• <DFN> The defining instance element is used to create a sub-definition in a defining list.
Variables are normally viewed in an italic font.
Note that all of these elements are containers, and as such, they require an end tag. Figure 6.1 shows
how these logical elements look when seen in the Netscape viewer.
You have probably noticed that a lot of these format styles use the same rendering. The most obvious
question to ask is why use them if they all look alike?
The answer is these elements are logical styles. They indicate what the intention of the author was, not
how the material should look. This is important because future uses of HTML may include programs
that search the Web to find citations, for example, or the next generation of Web viewers may be able
to read a document aloud. A program that can identify emphasis would be able to avoid the deadly
monotone of current text-to-speech processors.
You may have the opportunity to quote a long piece of work from another source in your document.
To indicate that this quotation is different from the rest of your text, HTML provides the
<BLOCKQUOTE> element. This container functions as a body element within the body element and can
contain any of the formatting or break tags. As a container, the <BLOCKQUOTE> element is turned off by
using the end tag.
The normal method used by most viewers to indicate a <BLOCKQUOTE> element is to indent the text
away from the left margin. Some text-only viewers may indicate a <BLOCKQUOTE> by using a character,
such as the "greater than" sign, in the leftmost column on the screen. Because most viewers are now
graphical in nature, the <BLOCKQUOTE> element provides an additional service by enabling you to
indent normal text from the left margin. This can add some visual interest to the document.
Listing 6.1 shows how a <BLOCKQUOTE> is constructed, including some of the formatting available in
the container. The results of this document when read into Netscape can be seen in Figure 6.2.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page 60
Shree M .& N. Virani Science College
Having said that HTML is intended to leave the appearance of the document up to the viewer, I will
now show you how you can have limited control over what the reader sees. In addition to the logical
formatting elements, it is possible to use physical formatting elements that will change the appearance
of the text in the viewer. These physical elements are as follows:
• <B> The bold element uses a bold font to display the text.
• <TT> The teletype element displays the contents with a monospaced typewriter font.
• <STRIKE> The strikethrough element draws a horizontal line through the middle of the text.
• <BIG> The big print element uses a larger font size to display the text.
• <SMALL> The small print element displays the text in a smaller font size.
• <SUB> The subscript element moves the text lower than the surrounding text and (if possible)
displays the text in a smaller size font.
This is a SUB>subscript</SUB>.
• <SUP> The superscript element moves the text higher than the surrounding text and (if
possible) displays the text in a smaller size font.
This is a <SUP>superscript</SUP>.
If the proper font isn't available, the reader's viewer must render the text in the closest possible manner.
Once again, each of these is a container element and requires the use of an end tag. Figure 6.3 shows
how these elements look in the Internet Explorer.
These elements can be nested, with one element contained entirely within another. On the other hand,
overlapping elements are not permitted and can produce unpredictable results. Figure 6.4 gives some
examples of nested elements and how they can be used to create special effects.
TIP: There is a tag available only in Netscape Navigator that has acquired a particularly bad
reputation: the <BLINK> tag is notorious in HTML circles. Unless you want people to speak ill of your
documents, it's best to avoid this tag. If you do use it, make absolutely sure you remember to use a
</BLINK> tag in the proper place. There's nothing more annoying than a whole page of blinking text.
Fonts
You, as document author, have the ability to control the appearance of the text in your documents. This
capability was restricted entirely to the reader in versions of HTML previous to 3.2. The problem with
this ability is that you can only use fonts that exist on you readers' machines. So how do you know
what your user might have available?
Unfortunately, you don't. If you are building documents to be used on an intranet, your organization
should set standards as to which fonts should be found on every machine. As long as this is a
reasonable set, it will be easy to maintain and you will be able to choose any of the standard fonts for
your document. If you are developing for the Web, however, you have a more serious problem. In
practice, you really don't know what fonts your readers might have. Even the most basic selection
depends greatly upon the hardware that your readers are using. There are no really graceful ways
around this problem at the present, although several companies are looking into ways of distributing
font information with a document.
NOTE: If you are developing for the Web and you would like to use some different fonts, you should
be aware that Microsoft has several fonts available for free download on their Web site. These fonts
are available in both Windows and Macintosh formats. If you decide to use any of these fonts in your
documents, you might want to put a link to the Web page where your readers can download the fonts,
if they don't already have them.
http://www.microsoft.com/truetype/fontpack/default.htm
The FONT element can be used inside of any other text container and it will modify the text based upon
the appearance of the text within the parent container. Using the FACE, SIZE, and COLOR attributes, you
can use FONT to drastically modify the appearance of text in your documents.
The FACE attribute allows you to specify the font that you would like the viewing software to use when
displaying your document. The parameter for the this attribute is the name of the desired font. This
name must be an exact match for a font name on the reader's machine, or the viewer will ignore the
request and use the default font as set by the reader. Capitalization is ignored in the name, but spaces
are required. Listing 6.2 shows an example of how a font face is specified and Figure 6.5 shows the
page in Microsoft Internet Explorer.
Since you don't know for certain what fonts the user might have on his system, the face attribute allows
you to list more than one font, with the names separated by commas. This is especially useful, since
nearly identical fonts often have different names on Windows and Macintoshes. The font list will be
parsed from left to right and the first matching font will be used. Listing 6.3 shows an example where
the author wanted to use a sans-serif font for his text.
Listing 6.3 Font Face Selection can use a List of Acceptable Choices
<HTML>
<HEAD>
<TITLE>Font Selection Example</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana", "Arial", "Helvetica">
This is an example of font selection. </FONT>
</BODY>
</HTML>
In this example, the author wanted to use Verdana as his first choice, but listed Arial and Helvetica as
alternatives.
Listing 6.4 shows how the font sizes are specified and Figure 6.6 shows how they would look.
Text color can be specified in the same manner as the face or the size. The COLOR attribute accepts
either a hexadecimal RGB value or one of the standard color names. Listing 6.5 is an example of how
colors can be specified.
The <BASEFONT> tag is used to establish the standard font size, face, and color for the text in the
document. The choices made in the <BASEFONT> tag remain in place for the rest of the document,
unless they are overridden by a FONT element. When the FONT element is closed, the BASEFONT
characteristics are returned. BASEFONT attributes can be changed by another <BASEFONT> tag at any
time in the document. Note that BASEFONT is a tag and not a container. There is no </BASEFONT> end
tag.
BASEFONT uses the FACE, SIZE, and COLOR attributes just as the FONT element does.
Now that you have all of the tools to format your text, you need to decide how you are going to use
them. It is possible to use so many different fonts, sizes, and formats that your document will be
unpleasant to read. Figure 6.8 is a bad example of how a document can use too many formats.
The following are general tips to keep in mind as you format your documents:
• Most documents should use only two or three different font faces.
• In general, if the body text is in a serif font, such as Times New Roman, the headings should be
a sans-serif font, such as Arial.
• Italics are much less intrusive than are bold characters, which should be reserved for very
important points.
• Don't overuse underlining. When long strings of text are underlined, the user's eyes easily get
confused.
• The size of headings should decrease with the decreasing importance of the heading. This
provides your readers with a quick and easy way to scan your documents.
It's bound to happen sooner or later--you'll need to include some weird character on your Web page
like a copyright sign or trademark symbol. Fortunately, HTML provides an easy way to do this. For
example, if you need a trademark symbol, you use the substitute &trade. A Web browser program will
interpret this properly as ™.
HTML 4.0 adds a whole list of new "entities", or special symbols. They fall roughly into three
categories.
The second set of new entities are mathematical symbols. Long demanded by scientists and engineers,
these new symbols allow them to put complex formulas inline with regular text. An integral equation is
now almost as easy to create and display elegantly as a Shakespeare quote.
NOTE: Though Greek characters are included among the mathematical entities, the set is not adequate
for creating documents in Greek. These symbols are intended for use in mathematical formulas only.
The final set of new characters included in the HTML 4.0 specification is a set of special characters
that are included in Adobe's Symbol font, like daggers and fancy quotation marks.
Though entities are easy to use, the list of available characters is quite long. The full list is on the Web
at http://www.w3.org/TR/WD-entities, but Table 6.1 lists a few popular characters to get you started:
Entity Symbols
¢, £, ¥ ¢, #, ¥
©, ® ", ®
° °
¼, ½, ¾ 1/2 , 1/3, 3 /4
÷ ÷
&pi [Pi]
&le, &ge <>
& &
&dagger [dagger]
&spades, &clubs, &hearts, &diams ´, ®, §, ©
To use one of these entities in an HTML document, just include it inline with text, as in this example:
The & will be displayed as an ampersand ("&") and the &pi will show up as the mathematical
symbol for pi.
Chapter 7
Adding Graphics to a Web Page
Images can make your HTML document more compelling than text alone. Imagine an HTML
document that contains some fairly dry material. The specification for the techno-widget that you
invented, for example. If you only put text in this document, the document would seem quite dull. On
the other hand, a few well-placed graphics can break up the text, making it seem more readable, and
make the document more visually appealing.
Images can often convey your message better than text alone. Can you picture this book without any
figures? It wouldn't convey its message as well. Remember the old cliché, "a picture is worth a
thousand words?" Beyond that, without figures you probably would have put this book right back onto
the shelf because it wouldn't look very appealing.
Up to this point, you've learned about the basic HTML required to add text to your document and how
to format that text. This chapter stuffs your toolkit with another tool--inline images--that lets you
convey your message better and create a more visually attractive Web page. In this chapter, you learn
how to add those images to your HTML documents. You also learn several tips and tricks that you
need to know when using images in HTML.
You need to carefully consider each image that you add to your HTML documents. Yes, you should
carefully consider the design and contents of each image, but, in this section, you learn about other
issues. For example:
Before adding images to your HTML documents, you need to understand the issues. That doesn't mean
you should avoid using images--you shouldn't. If you understand the issues, however, you're better
able to choose appropriate images. Just keep these points in mind as you add each image to your
document:
• Graphics files are slow to download. The average user with a 14.4KBps modem can wait
several seconds or even several minutes while a graphics file downloads.
• Search engines don't know what to do with images. Search engines such as AltaVista and
Excite can't index your images. Thus, if you depend heavily on images, your Web page isn't as
likely to be hit upon by these search engines' users.
• Images aren't always internationalized. Such a big word, internationalized. Because HTML
documents published on the Web have a worldwide audience, internationalized images might
be important.
• Color images aren't always portable. A color image that looks good on your computer might
not look quite as good on another user's computer. Thus, you need to pay particular attention to
how you use colors in an image.
The growth in electronic publishing has given rise to a startling new crime wave. Many people who are
perfectly honest in all of their day-to-day dealings think nothing of using a clever graphic found on the
Web. After all, once they download it, the image has lost all its ties to the original author. Regardless,
copyright laws apply to electronic images just as much as they do to works like this book. If you use an
image that has been copyrighted, the author can sue for damages.
How can you tell if a graphic has been copyrighted? It's not as easy as looking for a little copyright
symbol in the image. Here are some tips to help you determine if an image is copyrighted:
• Look at the original document that contained the image for a copyright notice.
• If you borrowed the image from clip art or an image library, look in the library's document for a
copyright notice.
• If you scanned the image from a magazine or book, you can bet the image is copyrighted.
• If you downloaded an image from a commercial site, such as an online magazine, the image is
probably copyrighted.
NOTE: Images that are obviously commercially oriented are usually copyrighted. These include
images of people, logos, cartoon characters, and other unique images. Interesting decorations such as
bullets or horizontal rules probably come from a clip-art library, which grants rights to use those
images only to the purchaser of the library.
Can you plead ignorance if you're busted using a copyrighted image? No. You have the total
responsibility for determining whether an image is copyrighted. Because this is not always practical,
the best advise is to only use images that either you're completely certain are not copyrighted, those
that you have been granted the right to use, or those for which you hold the copyright.
CAUTION: Changing a copyrighted work does not revoke the copyright. The copyright holder has
rights to all derived works. This means that you cannot download an image, change it in some fashion,
and then freely use the new version.
As you can see, copyright law is a tricky thing. Your best bet is to assume that all images are
copyrighted unless proven otherwise. If you have any questions or if you're developing a high-profile
Web site, you should probably contact an attorney who specializes in copyright law.
Maybe. A simple rule of thumb is that you should avoid pornographic images. From a practical point
of view, a Web site that has pornographic images on it is likely to be overwhelmed with traffic. As a
result you may run afoul of your Internet service provider, who is almost certainly not going to be
pleased with hundreds of megabytes of downloads from a single Web page.
• Most pornography has been scanned from published sources and is in violation of the copyright
laws. These publishers are among the most aggressive plaintiffs in pursuit of legal damages.
• A variety of states and countries have laws regarding what is obscene. Since the Web is a
world-wide medium, you might violate laws that you don't even know exist.
CAUTION: The information you read in this section is common sense. This information doesn't
replace your legal counsel, however, in cases where you have real questions about pornographic
images.
You'll find dozens of graphics file formats that you can use to store images--GIF, JPEG, PCX, PNG,
WMF, and so on. When creating images for use in an HTML document, however, you're better off
sticking with those file formats that most browsers understand: GIF or JPEG.
Each file format has certain trade offs. While one file format downloads faster, for example, the other
format maintains more image detail. This section helps you pick the right file format by describing
these trade offs. First, it briefly describes each file format, and then it compares the speed, color depth,
definition, and browser support of each file format.
NOTE: If you want to get right to the bottom line, use GIF. It's widely supported by most Web
browsers (whereas PNG is not). It can be interlaced, which lets users view an image before it's finished
downloading. It does transparency, too, so you can create great looking imagemaps with transparent
backgrounds. And you can even use it to create simple animations.
NOTE: When choosing a graphics file format, the most important issue to keep in mind is download
speed versus image quality. If you're going to use an image in your Web page, you obviously want to
TIP: GIF does an extremely good job compressing images that contain only a handful of colors. Thus,
with an image that uses only a few colors, GIF compresses better than JPEG.
Colors
GIF supports 256 colors. JPEG supports 16.7 million colors. Thus, if color depth is not important or
you're using a limited number of colors in an image, you can be comfortable using GIF. On the other
hand, if you want to maintain a photographic-quality color depth, then you might consider using JPEG.
Loss
Lossy compression schemes cause an image to lose detail when the graphics program saves it. That is
how these schemes compress the file so much. Lossless compression schemes, on the other hand, don't
cause an image to lose any detail at all. Table 7.1 describes each file format's compression scheme.
Browser Support
You really don't want readers to have to install a helper application to view the images in your HTML
documents. Thus, you should stick with those file formats that are directly supported by the most
popular browsers. These formats include GIF and JPEG. PNG is not yet supported by a majority of the
Web browsers, so you should shy away from this format for now.
Putting an image in an HTML document is incredibly easy--simply use the <IMG> tag with its SRC
attribute, which points to the URL of the graphic file to be displayed (see Figure 7.1). Add the
<IMG SRC="filename">
By default, the browser displays the image inline. Thus, the browser displays it immediately to the
right of any text or any other object that immediately precedes the image. Take a look at Listing 7.1,
for example. It shows the same image three different times. Each time, the image is shown inline. That
is, the browser displays the image immediately to the right of any text preceding it as seen below.
TIP: Consider storing all your images in a single directory off your Web site's root folder. Then, you
can use relative paths in combination with the <BASE> tag (see Chapter 8, "Linking Documents
Together") to access your images without specifying a full URL.
By default, when you insert an image inline with text, the text is aligned with the bottom of the image.
Chances are good that you won't like this default alignment--it leaves a great deal of white space on the
page. You can change it, though, using the <IMG> tag's ALIGN attribute. Table 7.2 describes each value
you can assign to this attribute.
Value Description
TOP Aligns the text with the top of the image
Listing 7.2 shows an HTML document that inserts three images, each of which uses one of the
alignment values shown in Table 7.2. Figure 7.2 shows the resulting Web page.
By default, the browser displays images inline. That is, it displays an image immediately to the right of
the previous content. Text does not wrap around it. You can display an image on the left or right side
of the Web page, however, allowing the surrounding content to flow around the image. This type of
image is called a floating image.
You create a floating image by using the <IMG> tag's ALIGN attribute. This is the same attribute you use
to align the surrounding text with an image. Table 7.3 describes each value you can assign to this
attribute.
Value Description.
LEFT Displays image on left side and surrounding content flows around the image
RIGHT Displays image on the right side of the window and surrounding content flows around the
image
Listing 7.3 shows an HTML document that inserts two images, each of which uses one of the
alignment values shown in Table 7.3. Figure 7.3 shows the resulting Web page.
Providing the browser a size hint means that you explicitly state the height and width of the image
within the <IMG> tag. This has two benefits that make this a must:
• Size hints help users who've disabled inline image. If a user has disabled inline images and
you're not using size hints, he or she sees a small icon in place of the image. Thus, the Web
page is not formatted quite like you expect. Size hints cause the browser to display an empty
box that is the same size as the image.
• Size hints make the Web page render faster. A browser displays the HTML document first, then
displays the image. If you provide size hints for your inline images, the browser can display the
formatted HTML document while it finishes downloading the images. Thus, the user sees the
Web page faster.
If the size you specify by using the HEIGHT and WIDTH attributes isn't the same as the actual size of the
image as determined in your favorite graphics editor, the browser scales the image. The following
sections describe the result of scaling the image down or up.
Scaling an Image Down Scaling the image down means the actual image is larger than the space you
reserved for it by using the HEIGHT and WIDTH attributes. In this case, the browser shrinks the image so
that it fits in the reserved space. You can easily distort an image if you're not careful specifying its size.
For example, if you decrease the image's height by 50 percent and the width by 25 percent, the image
will look funny in the browser (see Figure 7.5).
CAUTION: Specifying a height and width that's smaller than the actual image's height and width
doesn't save any download time. The browser still downloads the entire image before it scales it to fit
the reserved area.
Scaling an Image Up Scaling the image up means the actual image is smaller than the space you
reserved for it by using the HEIGHT and WIDTH attributes. In this case, the browser enlarges the image
so it fits in the reserved space. Just as when scaling an image down, you have to be concerned with
maintaining an image's aspect ratio when you scale it up.
Unlike scaling an image down, however, you also have to worry with pixelation. That is, when you
enlarge an image, the image's contents are expanded to fill the area. The browser makes each pixel
bigger so that it fills more space. This effect is sometimes very unattractive, as shown in Figure 7.6.
So, you've dumped a bunch of images into your HTML document. What about those users who aren't
viewing images? You can provide alternative text to them that, at least, tells them about the image.
You do that with the <IMG> tag's ALT attribute, like this:
Listing 7.5 is an HTML document that uses alternative text to provide a description of the image.
Figure 7.7 shows you what this document looks like in a browser that's not displaying inline images.
By default, the user's browser displays a border around each inline image that you're using as an
anchor. You have a lot of control over that border and the white space around the image.
You set the <IMG> tag's BORDER attribute to the width of the border in pixels. If you want the border to
be 10 pixels in width, set this attribute to 10. Listing 7.6 shows an HTML document with three images,
each of which has a different border width. Figure 7.8 shows the result in the browser.
You might not like how the text surrounding an image crowds the image. If that is the case, use the
VSPACE and HSPACE attributes to add vertical and horizontal space around the image, respectively. You
set each of these attributes to the amount of space, in pixels, you want to allow between the
surrounding content and the image. Listing 7.7 shows an example of an image that adds additional
space around the image to separate it from the text. Figure 7.9 shows you the result.
Chapter 8, "Linking Documents Together," describes how to use an image as a link to another
resource. It's easy. You enclose an image within the <A> tag as shown here:
Chapter 8
Linking Documents Together
Hypertext is a term you'll frequently hear associated with the Web. A hypertext document is a
document that contains links to other documents, allowing you to jump between them by clicking the
links. It's also a term associated with help files and other types of documents that are linked together.
For example, if you've published a report that cites several sources, you can link the references of those
sources to related works. Likewise, if you're discussing the migratory habits of the nerd-bird, you can
provide links to Web pages where nerd-birds are known to frequent.
Hypermedia is based upon hypertext but contains more than text. It contains multimedia such as
pictures, videos, and audio. In hypermedia documents, pictures are frequently used as links to other
documents. You can link a picture of Edinburgh to a Web site in Edinburgh, for example. There are
countless types of multimedia you can include on a Web page, and some of those can serve as links to
other Internet documents and resources. Figure 8.1 shows you an example of a hypermedia document.
Understanding Links
A link really has two different parts. First, there's the part you see on the Web page called an anchor.
There's also the part--the URL reference--that tells the browser what to do if you click that link. When
you click a link's anchor, the browser loads the file or document given by the link's corresponding
URL reference. You learn about both parts of a link in this chapter's following sections.
Anchors
A link's anchor can be a word, a group of words, or a picture. Exactly how an anchor looks in the
browser depends largely on what type of anchor it is, how the user has configured the browser to
display links, and how you created it. There are only two types of anchors: text and graphical.
Text Anchors Most text anchors look somewhat the same. A text anchor is one or more words the
browser underlines to indicate the fact that it represents a link. The browser also displays a text anchor
using a different color than the rest of the surrounding text (the color and appearance of links are under
the author's and user's control). Figure 8.2 shows a Web page that contains three text anchors. In
particular, notice how the text anchors on this Web page are embedded in the text. That is, they aren't
set apart from the text, like the references in this book, but are actually an integral part of it. Clicking
one of these links loads a Web page that is related to the link. Many text anchors are used this way.
The HTML for the first text link looks a bit like this (the <A> tag is discussed in "Linking to
Documents and Files," later in this chapter):
Graphical Anchors A graphical anchor is similar to a text anchor. When you click a link's graphical
anchor, the browser loads the Web page that the link references. Graphical anchors aren't underlined or
Versatility is the strong suit of graphical anchors. You can use them for a variety of reasons. Here are
some examples of the ways you find graphical anchors used on a Web page:
• Bullets. Graphical anchors are frequently used as list bullets. You can click the picture to go to
the Web page described by that list item. Frequently, the text in the list item is also a link. You
can click either the picture or the text.
• Icons. Many Web sites use graphical anchors in a similar manner to Windows 95. They are
common on home pages, and represent a variety of Web pages available at that site. Figure 8.4
shows a Web site that uses graphical anchors in this manner. The HTML for the icon on the left
side of this Web page that says What's New might look a bit look this:
• Advertisements. Many Web sites have sponsors that pay to advertise on the site. This makes the
Web site free to you while the site continues to make money. You usually find advertisements,
such as the one shown in Figure 8.5, at the top of a Web page. Click the advertisement and the
browser loads the sponsor's Web page.
URL References
The other part of a link is the URL reference. This is the address of the Web page the browser loads if
you click the link. Every type of link, whether it uses a text or graphical anchor, uses either a relative
or absolute reference.
Relative References An URL reference to a file on the same computer is also known as a relative
reference. That means that the URL is relative to the computer and directory from which the browser
originally loaded the Web page. If the browser loads a page at http://www.mysite.com/page, for
example, then a relative reference to /picture would actually refer to the URL
http://www.mysite.com/page/picture. Relative references are commonly used to refer to Web pages on
the same computer.
NOTE: Relative references work differently if you use the <BASE> tag in your HTML file. If you do
use the <BASE> tag, relative references are always relative to the URL given in the tag. They're not
relative to the URL page on which the reference appears. For example:
<BASE HREF="http://www.tuna.com/~mypages">
<A HREF="index.htm">
The link in the second line would refer to http://www.tuna.com/~mypages/index.htm, no matter where
the page itself was physically located.
Convenience is the primary reason you use a relative reference. It's much simpler to just type the file
name instead of the entire URL. It also makes it easier for you to move Web pages around on the
server. Because the URL references are relative to the Web page's computer and directory, you don't
have to change all the links in the Web page every time the files move to a different location.
Now that you have the terminology down (anchors, links, relative references, and so on), you're ready
to start adding links to your own Web pages. It's very simple. You have to tell the browser what
element in the HTML file is the anchor and the address of the Internet document or resource to which
you're linking. You do both things with one tag: <A>.
The following example shows you what the <A> tag looks like. This is its simplest form used for
linking to another Web page on the Internet. Its only attribute is HREF, which specifies the URL to
which you're linking. The URL can be any valid absolute or relative reference, such as
http://www.server.com/home/index.htm. Since the <A> tag is a container, you must put the closing </A>
tag on the other side of the anchor. That is, the opening <A> tag tells the browser where the anchor (text
or graphical) starts and the closing </A> tag tells the browser where the anchor ends. This is an
example:
<A HREF=URL>Anchor</A>
The following bit of HTML shows you how to add a text anchor to your HTML file. In this example,
HREF references Jerry Honeycutt's home page on the Internet. The anchor, which is underlined in the
Web browser, is Jerry Honeycutt's. The text before and after the <A> container isn't part of the
anchor and is therefore not underlined. For that matter, nothing happens when the user clicks the text
outside the container. On the other hand, when the user clicks Jerry Honeycutt's, the browser loads
the home page in the browser. Figure 8.6 shows what this anchor looks like in Internet Explorer.
NOTE: The examples you've seen thus far use absolute references. You can also use relative
references. Relative references can get a bit out of hand, however, if you store different Web pages in
different directories. You'll have a difficult time remembering exactly in which directory an HTML file
is stored, and thus, how to formulate the relative reference.
To remedy this problem, you can add the <BASE> tag to the top of your HTML file. In the absence of
the <BASE> tag, all relative references are based upon the URL of the current HTML file. Adding the
<BASE> tag provides an URL on which all relative references in the HTML file are based. It affects
relative references in every HTML tag, including the <A> tag, <IMG> tag, and so on.
Thus, if you add
<BASE HREF="http://www.server.com">
to your HTML file, all relative references are based upon that address, instead of the address of the
current HTML file. In this case, the relative reference, images/face.gif, would resolve to
http://www.server.com/images/face.gif.
Note that the <BASE> tag's original intention was to provide the URL of the document in which it's
found. This allows folks who are viewing the document out of context to locate the document on the
Internet. It works perfectly well for the purpose of dereferencing relative URLs, however, and is
documented by W3C in this manner.
TIP: Some browsers support ToolTip-style help for links. That is, when the user holds the mouse over
a link for a certain period of time, the browser displays the contents of the <A> tag's TITLE attribute in
a small pop-up window. Thus, if you want to provide additional information about the link to the user,
assign it to the TITLE attribute, like this: <A HREF="page.html" TITLE="Go to page.html">.
The previous example showed you how to create a text anchor. Creating a graphical anchor isn't much
different. Instead of enclosing text in the <A> container, you enclose an image. Consider the following
HTML, which is similar to the previous example. Figure 8.7 shows what it looks like. The HREF
references Jerry Honeycutt's home page, but instead of using a text anchor, it uses the <IMG> tag to
create a graphical anchor. When the user clicks anywhere on the picture, the browser opens the Web
page referred to by the <A> tag.
NOTE: Imagemaps are becoming much more common. They let you map certain portions of an image
to different URLs.
Internal Links
As well as providing links to other HTML files, you can link to an anchor within the current document.
For example, you can provide a table of contents for the current Web page at the top of the page. You
can then link each entry to a different section within the current Web page.
There are two steps to this. First, you must create an anchor in the HTML file that indicates the
location to which you're linking. For example, if you want to provide a link to the middle portion of
your Web page, you'd create an anchor in the middle and give it a name using the NAME attribute. You
name the anchor so that you can refer to that name in your link. Note that because you're only naming
an anchor, instead of creating a link, you don't set the HREF attribute. You still have to use the opening
and closing <A> tags, but the browser doesn't highlight the contents of the <A> tag because you're not
using it as a link. Here's what the named anchor looks like:
After you've created the named anchor, you create a link to it. You use a special notation to link to that
anchor. Instead of setting the HREF attribute to the URL of another Web page, set it to the anchor's
name, prefixing the anchor's name with a pound sign (#). Consider the following example. The HREF
attribute refers to the named anchor shown in the previous example. The name is prefixed with the
pound sign to indicate to the browser that you're making an internal link. When the user clicks Jump
to the middle, the browser aligns the anchor in the previous example to the top of the browser
window.
NOTE: Some browsers do not move the named anchor to the top of the browser window if the anchor
is already displayed in the window. That is, if your internal link is at the top of the Web page, and the
You can also add a name to most elements using the ID attribute. For example, you can add a name to
a Header element like this:
You could then link directly to the name assigned by the ID attribute with this link:
When the user clicks a link to another Web page, the browser opens that Web page in the browser
window. On the other hand, if the user clicks a link to a different type of document, it downloads the
document to the user's computer and then decides what to do with it. One of two things happen as a
result:
• The browser knows how to handle the file, which is the case with many graphics formats, and
displays the file in the browser window. For example, if you create a link to a GIF file and the
user clicks that link, the browser downloads the GIF file, clears the current Web page from the
browser window, and displays the GIF file in the window, as shown in Figure 8.8. In some
cases, however, the browser can use a plug-in to display the file in the browser window without
actually opening a separate window, even though the browser itself doesn't know what to do
with the file.
• The browser does not know how to handle the file, which is the case for a variety of documents
and many types of plug-in content. In this case, the browser downloads the file and looks for a
helper application that knows what to do with it. If it finds one, it launches the helper
application and passes it the downloaded file. For example, if the user clicks a link to an AVI
video, the browser downloads the file, finds a helper application to play AVI files, and launches
that file in the application. In most cases, the application displays the file in a separate window,
as shown in Figure 8.9.
TIP: Digital Infoworks sells a product called Cyberlinks that you can use to create links in any OLE-
enabled product, such as Wordpad. This means you can create hypertext links in your documents just
like you can in your Web pages. For more information, see http://www.pioneersys.com.
Whereas the <A> tag is used to create hyperlinks that a user can follow when he or she wants to, the
LINK element is used to connect various resources to an HTML document. Style sheets, color palettes,
international versions of the document, scripts, indexes, notices--all can be tied to an HTML document
One basic application for the <LINK> tag is to link a document to a style sheet, like this:
This line would link the document to the style sheet "OurStyle.css" for display on a monitor screen.
You can find out more about style sheets in Chapter 17, "Applying Cascading Style Sheets."
The <LINK> tag can also be used to define a document's relationship to another document. For
example, if your document was a section of Chapter 4 in an HTML hyperbook, that might be indicated
with this line of code:
The document "Chapter4TOC.html" would be the table of contents that linked to the current
document, and the LINK tag indicates that it is the parent document to the one you're reading. Note that
the <LINK> element doesn't display anything in the browser window--it's simply there as a reference
tool for you and for search engines and Webcrawler robots.
The "Chapter4TOC.html" file used in the previous example would contain the following line:
The REV attribute indicates the reverse relationship from the REL attribute. That is, it shows that a page
is "superior" to the referenced document.
REV and REL attributes can take just about any value, though there is some ongoing effort to create
some standardized values to make relationships between documents clearer. Here are some of the
proposed values for REV and REL:
Value Indicates
Parent Parent document
Index Index document
Previous Previous page
Next Next page
Contents Contents page
Alternate Alternate version
Begin Beginning page
A value of Alternate indicates that the referenced document is an alternate version of the current
page. This can be for a version for print, for example, or even a page in an alternate language. In this
case, you'd add an additional attribute, LANG, to show the language of the linked version. For example,
the following would indicate an alternate page in French:
The initial example a few paragraphs back used the value MEDIA=screen to indicate that the stylesheet
being linked to was for display on a video screen. It could have just as easily said MEDIA=print to
indicate a print version.
The World Wide Web is a popular part of the entire Internet, but many others resources are available.
Most of them were around long before the Web was even born and, as a result, they have a lot of stuff
on them. Also as a result of the Web's newness, the other resources sometimes have a much wider
audience base. Whether you're designing a home page for yourself or for your company, you may want
to know how to link to those resources.
These resources can take various shapes, from the peanut gallery that is Usenet news, to personal e-
mail, to the capability to access other computers through Telnet. Although you can create your own
versions of these resources using forms, most of the time you wouldn't want to do so. For example, you
could easily create a page with many HTML form tags, text elements, and a submit button for e-mail,
but simply creating a link to e-mail with a particular address would be easier. This way, you can more
easily update the page because you don't have to worry about which forms to read. Also, sometimes
browsers have built-in support for some of the other resources, giving the user faster response time.
You especially want to create links to other resources on the Net if you're already using a resource. If
you already have a Gopher site with information that's updated automatically, why rebuild it to fit the
Web? Just adding a hyperlink to your Gopher site makes more sense. Similarly, if you're running a
BBS that's on the Internet, putting in a Telnet link to it makes more sense. There's no reason for
recreating, or even mirroring, your BBS through forms for the Web.
The single most popular activity on the Internet is sending e-mail. More people use e-mail than any
other resource on the Net. The reason is quite simple: If you're on the Internet, you have an e-mail
address. The provider that gives you access to the Net often has at least one e-mail program available
for your use. Most modern e-mail programs offer a friendly interface, with no complex commands to
learn.
You'll most likely want to put in an e-mail link when you want people to give you feedback on a
particular topic. Whatever it is you want comments on--be it your home page or your company's
product--if you want to know what people think, use an e-mail link. E-mail links are also useful for
reporting problems, such as a problematic or missing link. Typically, the Webmaster of a particular site
should put these types of links to him or herself. You really have no reason not to put in a link to your
e-mail address.
Creating a link to an e-mail address is similar to creating a link to another home page. The only
difference is the reference for your anchor element. Normally, you put a link to a home page around
some text as in the following:
The link created with the preceding HTML looks like any other hypertext link. You can easily mix and
match hyperlinks to different resources, and they'll all look the same (see Figure 8.10). When this link
is selected, the browser opens its own e-mail interface for the user. Each interface is different, but most
of them automatically get your e-mail address and real name, and prompt you for a subject.
Because the e-mail link is a standard URL and easily implemented, many browsers have built-in
support for it. As a result, when people click an e-mail link, the Web browser will put up a primitive
mail program. A few companies offer a full set of Internet applications, from an e-mail program, to a
newsreader, to a Web browser. Oftentimes, these work in conjunction with each other. Consequently,
when you click an e-mail link, these Internet packages start up their own e-mail programs
Usenet is one of the best--or worst--resources on the Net, depending on whom you ask. Anybody with
an opinion can tell you what he or she thinks. They may not know what they're talking about, but
they'll let you know their opinion. Usenet is the ultimate embodiment of the freedom of speech, letting
everybody say anything they want.
The opportunity for anybody, anywhere on the Net to have a voice could be an asset to your home
page. Often, you may want to put in a link to Usenet when you want people to read for more
information. If your home page has some information about HTML authoring, for example, you might
want readers to go to a particular newsgroup for more help. You can also include such a link so people
can see what the differing opinions are. If you have a certain political view and want others to see what
the opposition is, a Usenet news link would be helpful.
Creating a link to a Usenet newsgroup is pretty simple; this kind of link is also just a derivative of the
basic hypertext link. As you did with the e-mail link, you need to modify two parts in the anchor
reference. When you're creating a Usenet link, enter news: instead of http:. Likewise, instead of
specifying a particular URL, put in a specific newsgroup, as follows:
As you can see in Figure 8.12, the Usenet news hyperlink looks identical to other links. When a user
selects such a link, the browser tries to access the user's Usenet news server. If the news server is
available to that person, the browser goes to the specified newsgroup. The user can then read as much
as he or she likes in that particular group.
CAUTION: When a user clicks a Usenet news link, his or her browser tries to access the newsgroup
in question. Because it's this user's browser and environment, he or she might not have access to the
group you specified. Not all Internet providers have access to the same newsgroups. When you're
creating such links, be mindful that not everybody will necessarily be able to access them.
How a Usenet hyperlink is handled is left entirely up to the Web browser the person is using. Many of
them treat each article in a newsgroup as an individual hyperlink. Often, there's little in the way of
sophisticated newsreading features. Some companies such as Netscape and Microsoft offer an entire
suite of programs, including a Usenet newsreader (see Figure 8.13). In these cases, the newsreader of
that suite is started.
Another popular activity is accessing an FTP site. FTP, or File Transfer Protocol, allows users to copy
files from other computers (the FTP site) onto their own computers. This popular method allows
companies to distribute their demonstration software or patches to their products.
Putting in a link to an FTP site allows users to get a specific file from a particular location. This
capability is useful for companies and shareware authors in making their products available. This type
of link is also great for people who review software, allowing them to let users get the files being
reviewed. People who have files (such as FAQs and interesting pictures) that they want others to get to
easily might want to put in a link to an FTP site.
You create a link to an FTP site the same way you create other links, and they look the same, too (see
Figure 8.14). Enter ftp: instead of the usual http:, and change the URL address to //sitename/path.
Simply put, the site name looks the same as the URL address. You need to make sure the site name
you specify points to a machine that accepts anonymous FTP connections. FTP links are almost always
supported by the browser natively. You can create a typical FTP link as follows:
If you don't specify a particular file name, the browser lists the files in the directory you specified. This
is particularly useful if you want the user to have access to multiple files. Programs available on
multiple machines, or large files broken up into several chunks, typically fall into this category.
Technically speaking, there isn't too much of a difference between FTP and the Web. As a result, Web
browsers support FTP links without needing another program. The browsers gives you a list of the files
in the current directory, and indicates which are directories and which are files (see Figure 8.15). If you
click a directory, it changes into that directory. If you click a file, the browser directly downloads the
file.
TROUBLESHOOTING: Some people can't access some of my FTP links. If a lot of people are
reporting inaccessibility to some of your FTP links, try finding other sites. This error usually comes up
when you have an FTP link to a particularly busy FTP site. You should try to locate other (less busy)
FTP sites that have the same file to which you're pointing.
NOTE: By default, when FTP links are activated, the FTP connection that's made is known as
anonymous FTP. This means that the FTP site the user is trying to access doesn't care who the user is.
All the anonymous FTP site cares about is sending and receiving files to anybody who logs in with the
NOTE: You can easily change an anonymous FTP link into a nonanonymous one. Simply put a
username and an at symbol (@) sign before the site name. This causes most Web browsers to
automatically attempt to log in as username. The browser then prompts the user for the password for
the login ID.
Before there was the World Wide Web, there was something known as Gopher. It was originally
designed by the University of Minnesota (the Golden Gophers) as a way of making information that
was spread out easily available. Gopher has probably been the Internet resource most affected by the
Web, often being superseded by it. The biggest difference between Gopher and the Web is that it is
very difficult for individual people to create their own Gopher sites or holes.
Although Gopher sites are not as prevalent as they once were, they still have a strong following. You
can typically find Gopher sites at places that dispense a lot of automated information. Although the site
could have easily been converted to HTML, it simply hasn't bothered. This conversion of Gopher data
into usable HTML code is typically the work of a programmer, and often not worth the effort. Putting
in an HTML link to a Gopher site allows people browsing your page easy access to a great deal of
information.
You can create a link to a Gopher hole by modifying the same two elements of the anchor reference.
Change the http: to gopher:, and change the URL to //sitename. The site name must be a valid Internet
host name address. The link created looks like every other type of hypertext link, and built-in support
is provided by most Web browsers. A Gopher hole link usually looks something like the following:
Just like FTP, Gopher is a Net resource that is built into HTML. Consequently, most Web browsers
support any links to a Gopher site internally. That is, you don't need a Gopher- specific application to
go to a Gopher site, the browser takes care of it for you. But also just like FTP, the built-in support for
Gopher is often very bland (see Figure 8.16).
WAIS stands for Wide Area Information System, which basically means "lots of large databases you
can search through." WAIS was specially designed by WAIS Corporation as a way of accessing large
amounts of information. This capability is very different from what Gopher and the Web do in that
WAIS is typically accessed through a search engine because most people don't want to plod through
such large stores of information. When WAIS was first introduced, custom front ends allowed easy
access to a WAIS database. With the advent of the Web, however, most WAIS databases now have
HTML front ends to their databases. Now you can simply fill out a Web form and click a button, and
the WAIS search is underway.
You can create a link in your home page to a WAIS database as easily as you do with all the other
links. You have to modify the same two anchor reference elements to hold the correct information.
Instead of using http:, enter the prefix wais:, and change the URL location to the address of a WAIS
database:
NOTE: Most browsers don't have built-in support of WAIS database searches. If you put in a link to
one of these databases, be sure to include some sort of reference to where users can get a WAIS client.
Of course, if the WAIS database you're pointing to has HTML forms support, you don't need to worry
about including such information.
The capability to access other computers is not something new to the Web; it's been around for a long
time. This access has always been achieved with a UNIX program called Telnet, which doesn't stand
for anything in particular. Telnet allowed people to try to log into a remote machine, much the same
way some people access their Internet providers. The Web allows for support of accessing remote
machines through a Telnet link to a remote computer.
Usually, people trying to get on a secure system are the people for whom you want to provide a Telnet
link. People who provide access to a private, Internet-accessible BBS will most likely want to put in a
Telnet link. Also, companies that offer a BBS for customer support may want to make use of link to a
Telnet site. Generally speaking, for most home pages, you have little or no reason to include a link to a
remote site.
As you might have guessed, creating a Telnet link to a remote site requires modifying the anchor
reference element. You change the http: to telnet:. You also need to change the URL part of the anchor
reference to hostname. Hypertext links that refer to Telnet sites look the same as other links. A typical
Telnet link takes the following form:
NOTE: Web browsers do not support Telnet activity natively. They typically depend on an external
application to talk correctly to the remote machine. If you put in a link to Telnet to another site, be sure
to also include some reference to a Telnet client.
Even though Telnet is a rather simple Net resource, it also has some problems. Among the many
problems are issues of how to display the remote session and how to interpret keypresses. As simple as
these problems may appear, they're hard to implement in a Web browser. For these reasons, most Web
browsers don't have support for Telnet. Rather, they leave it up to the individual to find a Telnet
program and set it up (see Figure 8.17).
TIP: Some Web browsers allow something extra in the anchor reference. Simply add the username
you want the person to log on as, followed by the @ symbol, before the site name. Instead of
Access my <A HREF="telnet://mysite.com/">system!</A>
you can have
Access my <A HREF="telnet://john@mysite.com/">system!</A>
On those browsers that support this, the Web browser pops up a little notice. This notice tells the user
what login name should be used to access the system.
You may be wondering how well these hypertext links work with each other. The answer is "Very
well." Even though the links are different, they all look and behave the same. This common behavior
exists because of the anchor reference that all hyperlinks use. Some may need client programs not built
into a Web browser, but that's not a big deal. This identical look and feel of various hypertext links
allows home pages to have a consistent feel. Consistency in a home page is important because it allows
people to intuitively know they're in your home page without looking at the current URL.
The best thing you can do is to treat all hypertext links in the same manner, with slightly different
formats. Just take the same basic anchors, add a reference, and put in the correct pointer to that
reference (see Table 8.1). As a Web author, you must always remember that each person looking at
your home page could be using any browser available. No hard and fast rules about what resources all
browsers will support even exists. Whatever resource you want to link to, though, try to include a link
to a location where the user can get a client.
Chapter 9
Adding Lists to a Web Page
A basic list in HTML consists of a list-identifier container plus the standard list items tag. (In HTML,
all list items use one tag, <LI>, while the lists themselves are differentiated by their container tags.) An
ordered list, also called a numbered list, is used to create a sequential list of items or steps. When a
Web browser sees the tag for an ordered list, it sequentially numbers each list item by using standard
numbers (1, 2, 3, and so on).
Ordered (or numbered) lists begin with the <OL> tag, and each item uses the standard <LI> tag. If
needed, you can create a list heading by using the <LH> tag. Close the list with the </OL> tag to signal
the end of the list. List containers provide both a beginning and ending line break to isolate the list
from the surrounding text; it's not necessary (except for effect) to precede or follow the list with the
paragraph <P> tag.
NOTE: Lists support internal HTML elements. One of the most useful elements is the paragraph tag
(<P>), which enables you to separate text in a list item. Other useful tags include both logical and
physical style tags (such as <EM> and <I>) and HTML entities. Headings are not appropriate for use in
lists; although they're interpreted correctly, their forced line breaks make for an ugly display. SGML
purists also object to them because heading tags are meant to define relationships in paragraphs, not
lists.
Listing 9.1 shows how you can use the OL list container. Pay particular attention to closing tags,
especially in nested lists. You can use leading blanks and extra lines to make your list code easier to
read, but Web browsers ignore them. Figure 9.1 shows how Netscape Navigator interprets this HTML
code.
It is also possible to nest ordered lists, creating a document that looks more like an outline. Listing 9.2
shows the HTML code for such a list, which is rendered in Figure 9.2.
TIP: Use indentations and blank lines to organize your data when creating HTML documents. Web
browsers don't care how the text is aligned or run together, but you will appreciate the extra effort
when rereading and editing the HTML code.
HTML 4.0 defines a handful of attributes for the <OL> tag, which began as a Netscape extension. Now
that these attributes have gained acceptance, they're part of the HTML specification.
Varying the marker style enables you to create distinctions between numbered lists in the same
document. Listing 9.3 shows how an HTML document incorporates these attributes, and Figure 9.3
shows how these attributes can enhance a document.
TROUBLESHOOTING: I'm creating a list of items and I need to interrupt the list for a regular
paragraph of text. How can I make the list pick up where it left off and continue numbering the items
sequentially? The HTML specification includes an attribute for the <OL> tag called START. Ideally then,
you could pick up, say, at item 7 by specifying <OL START=7>. The number 7 is just an example. Put
whatever value you want the numbering to start with.
HTML also supports the unordered or bulleted list, which is a list of items that does not define a
specific structure or relationship among the data.
Unordered lists (bulleted lists) use the <UL> container tag. Just like ordered lists, bulleted lists provide
beginning and ending line breaks and support internal HTML elements and sublists. Also, like ordered
lists, they require closing tags; include the </UL> tag to signal the end of the list. Web browsers
support and automatically indent sublists, and some also vary the bullet icon based on the relative level
of the list. These icons vary depending on the client software viewing the HTML document.
Listing 9.4 shows how to use the <UL> list container. Again, to make the HTML document easier to
read, you can include leading blanks and extra lines, but Web browsers ignore them. Figure 9.4 shows
how Netscape Navigator renders this HTML code.
Like the <OL> tag, the HTML specification adopted some of Netscape's extensions for the <UL> tag.
You can manually control the appearance of item markers as either circles, squares, or discs. This
feature is meant to give you more control over the look of bulleted lists.
You use the TYPE attribute to change the bullet used in the list. Its value can be one of disc, square, or
circle. Listing 9.5 demonstrates its use in an HTML document, which is rendered by Netscape
Navigator in Figure 9.5.
NOTE: Besides attributes for the <OL> and <UL> elements, HTML 4.0 also provides extensions for
individual list items. The extensions are based on those available to the list container that the item is in
(ordered or unordered). Ordered lists pass on the capability to change the current TYPE of list items and
also the VALUE they begin with--by using the <VALUE> tag, you can either begin a list with a value other
than one, or change the numbering within a list. This would be another good way to continue a list that
has been interrupted by some other type of HTML object. (All subsequent items adopt the extension
changes until the list closes.) You can modify unordered list items with the TYPE extension; all
subsequent items in the container use the item marker.
Like the <OL> tag, <UL> also supports the COMPACT attribute, which causes the browser to render the list
in a more compact form.
You can create menu lists with another list type supported by HTML and Web browsers. The
distinction here is primarily for HTML identification; most browsers' default display for the <MENU>
container is very similar to the font and style used for the unordered list container. The value of this
element is enhanced if you select a distinct screen format for the menu paragraph in a Web browser's
preferences. The container might also be more functional in future versions of HTML and its client
software, enabling browsers and other applications to identify the menu sections in your documents.
As with the previous lists, menu lists provide beginning and ending line breaks and can include other
HTML elements in a menu container. The anchor element is the most likely HTML element to use in
this type of list; it is used to link the menu listings to other document resources or Internet applications.
Listing 9.6 shows typical uses for the <MENU> container.
TIP: Just because HTML has specific names for these list types doesn't mean you're limited in how
you can use them. Experiment to see how each list delivers your information and use what works best.
Again, the current implementation of <MENU> by most Web browsers doesn't provide a visual
distinction between menu and unordered lists. Netscape Navigator displays menu lists and unordered
lists identically (see Figure 9.6), while Microsoft Internet Explorer displays them identically except for
the omission of bullets in the latter.
NOTE: Menu items (and other list types) can contain hypertext links to other documents or Internet
resources. Use the <A> container to create the links, as follows:
<A HREF="home.htm">Jump to My Home Page</A>
Click the text Jump to My Home Page, and the browser retrieves the document HOME.HTM.
The <DIR> element functions much like the <MENU> element; it provides HTML identification to the
section of text that has more potential usefulness than real functional value. Similar to <MENU>, <DIR>
containers display with the same default settings as unordered lists.
The intended use for the <DIR> container limits items to 24 characters and displays the items in rows
(like file directories in UNIX, or in DOS using the /W parameter). Current browsers don't support this
interpretation. The <DIR> element also isn't intended to include other HTML elements; browsers
interpret them correctly. When using <DIR>, remember to close the container with the ending </DIR>
tag. Listing 9.7 shows typical uses of the <DIR> container.
Definition lists, also called glossary lists, are a special type of list in HTML. They provide a format
like a dictionary entry, with an identifiable term and indented definition paragraph. This format is
especially useful when listing items with extensive descriptions, such as catalog items or company
departments. The <DL> element provides both a beginning and ending line break. In the <DL>
container, the <DT> tag marks the term and the <DD> tag defines the paragraph. These are both open
tags, meaning they don't require a closing tag to contain text.
<DL>
<DT>Term
<DD>Definition of term
</DL>
The <DT> tag's text should fit on a single line, but it wraps to the next line without indenting if it runs
beyond the boundary of the browser window. The <DD> tag displays a single paragraph, continuously
indented one or two spaces beneath the term element's text (depending on how the browser interprets a
definition list).
The HTML 4.0 specification provides an important optional attribute for <DL>: COMPACT. This attribute
is supposed to be interpreted as a list with a different style, presumably with a smaller font size or more
compact character spacing. This could be useful for embedded definition lists (those inside other
definition, numbered, or bulleted lists), or for graphic effect. Most browsers, however, ignore the
attribute, displaying the definition list to the standard format.
Definition lists can include other HTML elements. The most common are physical and logical styles
and other list containers. Although Web browsers can correctly interpret elements such as headings,
this is bad HTML; their forced line breaks are not pretty and heading tags are usually meant to define
relationships in paragraphs, not within lists. Listing 9.8 shows examples of how you can create
definition lists.
Figure 9.7 shows how this document displays in Netscape Navigator. Other browsers may format this
text differently.
TIP: In Netscape Navigator, use a horizontal rule, <HR>, on a <DD> tagged line in a definition list. The
rule indents with the rest of the <DD> lines, providing an easy-to-read separator for your definition text.
There are times when it's necessary to use sublists of more than one type within a single list. For
instance, you may have a numbered list that includes a list as one of the numbered elements. Instead of
just creating an ordered sublist, which numbers each of its items, you might prefer to display an
unordered list to differentiate the sublist (while avoiding ordering the information as well). HTML
supports embedded combinations of all list types. Listing 9.9 shows a sample of combined lists.
Three list types are used in Listing 9.9: numbered, bulleted, and definition. The primary list is a
numbered list of planets. Each planet has a bulleted sublist indicating the Roman god after whom it
was named, followed by its dictionary definition. The users' browsers are being relied on to indent
embedded lists; if more indentation were desired, the lists can be embedded inside additional, empty
lists. For instance, instead of
<OL>
<LI>Small example list
<LI>That I want to indent more
</OL>
<OL><OL>
<LI>Small example list
<LI>That I want to indent more
</OL></OL>
Because the primary difference between list types involves either the list item markers or the format of
the elements--and not the actual text representation itself--combined lists tend to display very well.
Figure 9.8 shows how the samples in Listing 9.9 display in a typical Web browser.
It is possible to create custom bullets with a little manual effort in your HTML code. Consider the
HTML code shown in Listing 9.10.
The <UL> and </UL> tags are used to instruct the Web browser to set up the formatting and indentation
to support an unordered list. However, no <LI> tags are used: Because you don't want the standard
bullets, you can't use the standard list-item tag. Instead, each item in the list is specified similar to this
example:
The <IMG> tag is used to specify and align the graphic you want to use as your bullet, followed by the
list item. Because you're not using the standard <LI> tag to set off each item, you need to use the <BR>
tag to insert a line break after each one. This HTML code is rendered as shown in Figure 9.9.
Chapter 10
Formatting Content with Tables
Introducing Tables
As a tool for government, commercial, educational, and personal Web applications, HTML has many
needs and expectations to meet. It's the language behind the most popular resource on the Internet and,
as such, is required to support a greater range of uses today than perhaps its original creators had first
imagined. For example, you might design a corporate Web site similar to a marketing brochure, while
you'd design a government publication to present static data in tabular form. In most cases, you can use
tables to better present these types of Web pages (my technical writing professor would be proud).
In print publications, tables are a basic design element. They're used to present data in rows and
columns. They make comparative analysis more understandable. They're also used (albeit invisibly) to
divide the printed page into sections for layout purposes. Tables should be a basic design element in
your Web pages, too.
On the Web, tables have been used for a while now, thanks to Netscape and subsequently Microsoft,
but they were not an official part of the HTML standard until HTML 3.2. This chapter shows you how
to use HTML tables to organize content on your Web page or even to help lay out your Web page.
HTML defines tables in much the same way it defines list containers. The <TABLE> element is the
container for the table's data and layout.
HTML tables are composed row by row: you indicate a new row with the <TR> (table row) tag, and
you separate the data with either the <TH> (table header) or <TD> (table data) tags. Think of the <TR>
tag as a line break, signaling that the following data starts a new table row. Table headers are generally
shown in bold and centered by WWW browsers, and table data is shown in the standard body-text
format. Whereas you can think of a row as a line in a table, a cell represents each box within the table.
The HTML for a basic table is shown in Listing 11.1. All of the HTML table elements used are
supported by the latest versions of the most popular Web browsers: Netscape Navigator, Microsoft
Internet Explorer, and NCSA Mosaic. This table, as rendered by Internet Explorer, is shown in Figure
11.1.
The basic HTML table tags shown in Figure 11.1 and Figure 11.2 are as follows:
• <TABLE></TABLE>--These HTML tags are the containers for the rest of the table data.
• <TR></TR>--Each row in the table is contained by these tags. You can optionally leave off the
closing </TR> tag.
• <TD></TD>--Defines a cell. Table data is contained within these tags. You can also nest
additional tables within a single cell. You can optionally leave off the closing </TD> tag.
• <TH></TH>--These table header tags are used to define headers, usually in the first row or
column of the table. You can optionally leave off the closing </TH> tag.
In addition to the basic tags shown here, some other characteristics should be noted from the example
shown in Figures 11.1 and 11.2:
• BORDER attribute--By using the BORDER attribute of the <TABLE> tag, borders are put around the
table. You set the value of this attribute to the number of pixels wide you want the border, like
this: BORDER=1. If you set this attribute to 0, the browser will not display a border.
• ALIGN attribute--The ALIGN attribute can be specified in the <TABLE> tag with possible values
of LEFT, RIGHT, and CENTER (the default is LEFT). HTML 4.0 specifies a new value for ALIGN
of CHAR, which implements alignment on a specified character, such as a decimal point.
• Table heads--In most browsers, table heads enclosed by the <TH></TH> tags are emphasized
and centered.
• Table data--In most browsers, table data enclosed by the <TD></TD> tags are shown in the
normal font and are left-justified.
NOTE: If you're concerned about browsers displaying your header text correctly (as emphasized text,
preferably in a bold font), you can use style tags to force the issue. Be careful what you wish for,
though; if you want an italicized font but the browser automatically formats the text bold, you can
wind up with bold italicized headers.
NOTE: HTML 4.0 adds several new attributes to many table tags that are meant to improve access for
international and disabled users.
For example, the AXIS="name" attribute for the <TH> tag lets you specify a spoken name for a table
head, which can be used by a text-to-speech synthesizer. A similar attribute, AXES="row,column", has
been added to the <TD>, or table data, tag to allow for speaking the row and column references for a
table cell.
Almost every table-element defining tag also now includes the ID, CLASS, LANG, and DIR attributes.
These define a named label, class definition, natural language, and text direction for table elements,
respectively.
Cells do not necessarily have to contain data. To create a blank cell, either create an empty cell (for
instance, <TD></TD>) or create a cell containing nothing visible (<TD> </TD>). Note that
is an HTML entity, or special character, for a nonbreaking space. Though you would think these two
methods would produce the same result, as you will see later in this chapter, in the section "Empty
Cells and Table Appearance," different browsers treat them differently.
It's not really necessary to create blank cells if the rest of the cells on the row are going to be blank; the
<TR> element signals the start of a new row, so the Web browsers automatically fill in blank cells to
even out the row with the rest of the table.
TIP: Tables are necessarily uniform with equal numbers of cells in each row and in each column. No
"L-shaped" tables (or worse!) allowed.
It is possible, through the use of the ALIGN and VALIGN attributes, to align table elements within their
cells in many different ways. These attributes can be applied in various combinations to the
<CAPTION>, <TR>, <TH>, and <TD> table elements. The possible attribute values for each of these
elements are as follows:
• <CAPTION>--The ALIGN attribute can be specified for this element with possible values of TOP
and BOTTOM (the default is TOP); this places the table caption above or below the table.
• <TR>--The ALIGN attribute can be specified for this element with possible values of LEFT,
RIGHT, and CENTER (the default is LEFT for table data elements and CENTER for table header
elements), and the VALIGN attribute can be specified with possible values of TOP, BOTTOM,
MIDDLE, and BASELINE (the default is MIDDLE). If specified, this will give the default alignment
for all the table elements in the given row, which can be overridden in each individual element.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
103
Shree M .& N. Virani Science College
The BASELINE element applies to all elements in the row and aligns them to a common
baseline.
• <TH>--The ALIGN attribute can be specified for this element with possible values of LEFT,
RIGHT, and CENTER (the default is CENTER), and the VALIGN attribute can be specified with
possible values of TOP, BOTTOM, and MIDDLE (the default is MIDDLE).
• <TD>--The ALIGN attribute can be specified for this element with possible values of LEFT,
RIGHT, and CENTER (the default is LEFT), and the VALIGN attribute can be specified with
possible values of TOP, BOTTOM, and MIDDLE (the default is MIDDLE).
These alignments are illustrated by the HTML document shown in Listing 11.2 and rendered by
Netscape Navigator in Figure 11.2.
Although this table is pretty ugly, it illustrates the capabilities of the different ALIGN and VALIGN
attributes, as follows:
• Table Caption: <CAPTION ALIGN=BOTTOM> places the caption underneath the table--overriding
the default value, which would put the caption on top.
• "Row 1":
o The <TD ALIGN=CENTER> in the third column overrides the default set in the <TR>
element for just this table element.
• "Second Row":
o The <TR VALIGN=BASELINE> aligns all of the cells in the row vertically so that their
baselines match.
o The <TH ALIGN=LEFT> in the first column overrides the default table header alignment
and aligns the table header along the left side.
o The <TR ALIGN=LEFT> sets a default horizontal alignment to the left margin for each
element in the row.
o The <TD VALIGN=BOTTOM> in the second column vertically aligns the element on the
bottom of the row.
o The <TD VALIGN=TOP> in the third column vertically aligns the element on the top of
the row.
o The <TD VALIGN=MIDDLE> in the fourth column vertically aligns the element in the
middle of the row. Because this is the default behavior (and hasn't been overridden in
the <TR> element for this row), this attribute isn't necessary.
NOTE: Sitting down with your favorite text editor and hacking out the HTML for a table isn't always
the best way to do it. There comes a time when a piece of paper and a no. 2 pencil are the best design
tools you can use.
Take a look at Figure 11.3. It shows a sketch for a table that has two rows and four columns. The first
two columns of the first row are joined, and the last two columns of the last row are joined.
NOTE: To make your HTML coding job easier, you can handwrite a <TABLE> tag above the table and
a </TABLE> tag below the figure. Then, handwrite a <TR> at the beginning of each row, and a </TR>
tag at the end of each row. Last, handwrite a <TD> and </TD> within each cell. If a cell is spanned, then
write the number of cells it spans next to the <TD> tag and indicate if it spans rows or columns. Figure
11.4 shows you an example of such a sketch.
NOTE: With your marked-up sketch in hand, you're ready to write the HTML. Start at the top and
work towards the bottom of the sketch in a left to right fashion. Type each tag as you encounter it. If
you noted that a cell is spanned, be sure to add the ROWSPAN or COLSPAN attribute to the <TD> tag. The
following listing shows you the HTML that results from the previous sketch. (Note that indenting the
code can help clarify the row and column breaks.)
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
105
Shree M .& N. Virani Science College
<TABLE>
<TR>
<TD COLSPAN=2> </TD>
<TD> </TD>
<TD> </TD>
</TR>
<TR>
<TD> </TD>
<TD> </TD>
<TD COLSPAN=2> </TD>
</TR>
</TABLE>
CHAR Alignment
HTML 4.0 specifies a new value for the ALIGN attribute called CHAR, or character alignment. This
implements a much-requested feature for tables: the ability to align content on a decimal point, colon,
or other common character. It is used in conjunction with a new CHAR attribute. Here's a sample of its
use:
The TR tag in this sample uses ALIGN=CHAR to specify that data in the cells in this row should be
aligned by decimal point. CHAR="." sets the alignment character as a decimal point, although it could
be any ASCII character.
The CHAR value for ALIGN can be used with the COL, COLGROUP, THEAD, TBODY, TFOOT, TR, TH, and TD
tags.
A new CHAROFF attribute can also be used to specify the character offset within a cell. For example,
CHAROFF="30%" would tell the browser to place the character specified by the CHAR= attribute at an
offset of 30% from the start of the cell.
CHAROFF="20px" means the same thing but uses the actual suffix to specifically denote pixels, "px".
You can also use "pt" to define a width in points, like this: CHAROFF="50pt". However, point widths
are generally useful only in documents that are being formatted for print output on paper, since they
have no absolute meaning on a monitor screen, which can be of any size.
Suffix Value
px, [none] pixels
pt points
pi picas
in inches
cm centimeters
mm millimeters
em em units
% percent of screen width
There are more sophisticated things that you can do with tables, both by using additional table
attributes and by different uses of some of the ones you already know about.
Within the TABLE element, HTML 4.0 now gives you a broad degree of control over where rules and
frames are drawn within a table.
The FRAME attribute specifies which sides of a frame to render. It has the following possible values:
VOID No Frame
ABOVE Top Side
BELOW Bottom Side
HSIDES Horizontal Sides
LHS Left-Hand Side
RHS Right-Hand Side
VSIDES Vertical Sides
BOX or BORDER All Four Sides
The value BORDER is included for backwards-compatibility with HTML 3.2. <TABLE FRAME=BORDER>
is the same as the older <TABLE BORDER>.
In addition to the new FRAME attribute for TABLE, there is also a new RULES attribute. The RULES
attribute is used to specify additional rulings in the table interior. For example, it can turn on rulings
between all columns, or between groups of rows.
NONE No rules
GROUPS Horizontal rule between all row groups and a vertical rule between all column groups
ROWS GROUPS rulings, plus horizontal rules between all rows
COLS GROUPS rulings, plus vertical rules between all columns
ALL Rules between all rows and all columns
CAUTION: At the time of this writing, neither Microsoft Internet Explorer nor Netscape
Communicator supported the HTML 4.0 additions of RULES and FRAME. Before adding these attributes
to your tables, make sure that support for them has been added to the major browsers.
As mentioned previously, the BORDER attribute to the <TABLE> element was the HTML 3.2 element that
created borders around table elements, and it has been retained in HTML 4.0 for backwards-
compatibility. Even though this attribute is off by default, for most conventional tables--those used to
organize information in a tabular format--borders are usually used to accentuate the organization of the
information. Consider the HTML document shown in Listing 11.3 and rendered in Figure 11.5. In this
case, the organization of the information is much easier to see in the version that includes borders.
However, HTML tables can be used in other ways, rather than for the simple tabular display of data.
They give an HTML author great flexibility in presenting information, grouping it, and formatting it
along with other information. Consider the HTML document shown in Listing 11.4 and rendered in
Rows and columns can be spanned--combined with adjacent cells to create larger cells for the data. For
instance, in a table with five rows and five columns, the first row could be spanned across all five
columns to create a banner header for the whole table. In the same table, each of the columns could
have elements that spanned multiple rows. It would be possible, through spanning, to create
rectangular table elements that span both multiple rows and columns, up to the full size of the table.
To span two adjacent cells on a row, use the ROWSPAN attribute with <TH> or <TD>, as follows:
<TD ROWSPAN=2>
To span two adjacent cells in a column, use the COLSPAN attribute with <TH> or <TD>, as follows:
<TD COLSPAN=2>
TIP: Don't forget to close your table data with the </TABLE> closing tag.
HTML 4.0 adds an additional attribute to TD, NOWRAP. If NOWRAP is present, cell contents disables
automatic text wrapping for that cell. However, this attribute has been defined only for backwards-
compatibility with current browsers and is functionally superseded by style sheets.
Listings 11.5 and 11.6 show an HTML document that makes use of row and column spanning. This
example is shown in Figure 11.7, which shows some of the trouble you can get yourself into with row
and column spanning. The table shown on the left is formatted correctly. However, HTML will allow
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
109
Shree M .& N. Virani Science College
you to overlap rows and columns if you aren't careful with your spanning, and the results of this can
(and usually will) be unpredictable.
NOTE: When you create larger cells in an HTML table, you might find your cell data acts a bit
unruly: not breaking properly, wrapping text when it shouldn't, and crowding too close to the cell
divisions. Like other HTML documents, tables support internal HTML elements, such as <BR> (to
create a line break in the data), hypertext link anchors, inline images, and even forms.
Use an HTML table in the same manner you would a spreadsheet: for data display, for creating data
layouts (such as inventory lists or business invoices), and for calculation tables (when combined with a
CGI script that can take your form input and generate output data that's displayed in your HTML
table). The uses for tables are limited only by your data and your creativity.
HTML 4.0 adds several tags for grouping rows and columns for the purpose of specifying common
attributes for those groups.
COLGROUP assigns width and alignment attributes for a group of columns. For example, if you had a
table with six columns and you wanted each of the first three columns to be 50 pixels wide and left-
aligned, each of the second two columns to be 100 pixels wide and character-aligned on a decimal
point, and the last column to take up the remainder of the screen width and right-aligned, you could
accomplish all of this formatting with just the following three lines of HTML:
Note that the SPAN attribute defines how many contiguous columns are in a COLGROUP group. If it's left
out, the value defaults to SPAN=1, or a single column.
TBODY, THEAD, and TFOOT perform functions similar to COLGROUP, but they group rows instead of
columns. THEAD and TFOOT define a group of rows to form a header or footer for a table, respectively.
TBODY is used to group rows in the body of the table. Each is a container--that is, it is made up of
corresponding begin and end tags, as in <TBODY></TBODY>--but the end tags for THEAD and TFOOT are
optional, as long as a TBODY tag immediately follows. This was done for compatibility with older
HTML tables.
Each row grouping container set must contain at least one TR, or table row, element.
A TFOOT block should actually precede the TBODY block, as browsers will logically insert the footer
when needed in breaking pages.
Each row grouping element uses the same attributes and values as the COLGROUP tag.
As mentioned earlier, there is sometimes a difference between an empty cell in a table and one with
nothing visible in it. This is particularly true with Netscape Navigator and Internet Explorer, which
will display the two differently. Consider the HTML document shown in Listing 11.7, which shows
two tables. In the top table, there are several empty table cells--cells with only white space in them,
which Netscape Navigator will not treat as data. In the lower table, these same cells have something in
them: the HTML entity  , which is a nonbreaking space (an invisible character).
As shown in Figure 11.8, Internet Explorer will display these two tables differently. As you can see
here, now it is mainly an aesthetic difference.
HTML introduces several attributes that you can use to increase the degree of control you have over
how tables are displayed. These attributes were once Netscape enhancements, supported by Internet
Explorer, but are now a part of the HTML standard. Listing 11.8 shows the HTML document for these
attributes, which are rendered by Internet Explorer in Figure 11.9.
• WIDTH attribute--This enables you to specify the width of the table, either in pixels or as a
percentage of the width of the browser window. You can also use this attribute with individual
cells.
• HEIGHT attribute--This enables you to specify the height of the table, either in pixels or as a
percentage of the height of the browser window. You can also use this attribute with individual
cells.
• BORDER attribute--This attribute puts a border around the table. You specify the width of the
border in pixels, like this: BORDER=2.
HTML makes no provision for setting a table or cell's color. However, both Netscape and Internet
Explorer provide extensions that let you change the color of cells and borders. You use the BGCOLOR
attribute to change the color of a cell's background, before any text or images are placed into the cell.
You use the BORDERCOLOR attribute to change the color of the border around the cell. Both Netscape
and Internet Explorer support these attributes.
The <TABLE>, <TD>, <TH>, and <TR> tags all support BGCOLOR and BORDERCOLOR attributes. Thus, you
can apply colors to the entire table, an individual cell, or an individual row of the table. The example in
Listing 11.9 shows you the HTML for three tables, which show you an example of each case. Figure
11.10 shows you how these tables are rendered in Internet Explorer.
NOTE: HTML defines the following color names. For your convenience, you'll also find the
equivalent hexadecimal RGB values next to each color.
BLACK #000000
SILVER #C0C0C0
GRAY #808080
WHITE #FFFFFF
MAROON #800000
RED #FF0000
PURPLE #800080
FUCHSIA #FF00FF
GREEN #008000
LIME #00FF00
OLIVE #808000
YELLOW #FFFF00
NAVY #000080
BLUE #0000FF
TEAL #008080
AQUA #00FFFF
Listing 11.10 shows an HTML document for a fairly simple table shown in Figure 11.11.
Some other ways of displaying this information, not using tables, are as follows:
• Use a list. Information that is relatively straightforward can be displayed instead as a list. This
information can be displayed just as well as a list, as coded in Listing 11.11 and rendered by
Internet Explorer in Figure 11.12.
• Use an image instead. By creating the table in a word processor, or even in your own copy of a
Web browser such as Netscape Navigator, and then taking a screen shot and cropping it down
to the size of the displayed table, you can include the table in your HTML document as an
image. This may not be the best alternative, however, as Web browsers that do not support
tables may not support images either.
• Use preformatted text. This will give you a table that is aesthetically unappealing, but it has the
advantage of being displayed correctly in just about every Web browser, including text-only
browsers such as Lynx. An example of this is shown in Listing 11.12 and Figure 11.13.
Table Examples
Consider the HTML document shown in Listing 11.13. This document includes graphics and text
information, and is meant to display it as a sort-of business card. This document is shown, as rendered
by Internet Explorer, in Figure 11.14.
To refine this Web page further, some of the information presented within it can be displayed
differently--in this case, by using an HTML list (an unordered list, but any other kind of list could be
used just as easily). The HTML code for this is shown in Listing 11.14; it makes sense to group lists of
data by using HTML list elements, and the ability to include these within a table allows the
information to be conveyed more clearly. The revised Web page is shown in Figure 11.15.
Another way to display this information is to use tables within a larger table. The list items are
composed of both a team name and a year (or range of years). Couldn't this information also be
displayed in a table? In HTML, you can nest tables within other tables.
Listing 11.15 shows the HTML code for the business-card Web page using nested tables. It is
displayed in Figure 11.16. Notice the nested tables are displayed with borders (and with cell spacing
and padding reduced to make them more compact), while the outer table used to structure the whole
page is not.
You can easily spruce up a table by using an image as the table's header. That is, instead of displaying
a plain-text heading for the table, create a snazzy image and use that instead. Listing 11.16 shows you
the HTML for such a table, and Figure 11.17 shows you this table rendered in Internet Explorer. There
are a couple of things you should note about this example:
• The width of the table is specified to be exactly the width of the image by using the WIDTH
attribute, like this: <TABLE WIDTH=500>.
• In the <TABLE> tag, CELLSPACING is set to 0 in order to make sure the image lines up with the
table correctly.
• The table heading is spanned across all columns in order to accommodate the image. In this
case, the tag <TH COLSPAN=2> spans across the top two columns of the table.
• The <IMG> tag is used to insert the image into the spanned columns. Note that the border is
disabled by using BORDER=0 and the height and width are set to the exact dimensions of the
image by using the HEIGHT and WIDTH attributes.
Figure 11.18 shows you an example of a home page that uses tables extensively for layout purposes.
This happens to be Microsoft's home page. Note that the toolbar at the top of the page is actually
defined as a table. As well, each layout region on this page is actually a cell within the table.
Chapter 11
Framing Your Web Site
First introduced in Netscape Navigator 2.0, HTML frames create independently changeable and
(sometimes) scrollable windows that tile together to break up and organize a display so that it's not
only more visually appealing, but easier to work with.
Frames are similar in many ways to HTML tables. If you understand how tables work, you'll have a
jump start on how to work with frames. If you want to check out how tables work before starting with
frames, see Chapter 11, "Formatting Content with Tables."
However, unlike tables, frames not only organize data, they organize your browser's display window.
In fact, they break up the window into individual, independent panes or frames. Each frame holds its
own HTML file as content, and the content of each frame can be scrolled or changed independently of
the others. In a way, it's almost as though each frame becomes its own mini-browser.
Perhaps the best way to get a feel for what you can do with frames is to look at a few real-world
examples.
As you might expect, Netscape--the inventor of frames--has some excellent examples of frames on its
Web sites. Figure 12.1 is taken from Netscape's DevEdge developer's site and shows a window that is
broken into four separate frames.
The frames on this page show how Netscape has split information display into the two frames on the
right, while reserving navigation functions for the two frames on the left.
The top-right frame--which occupies about 80 percent of the width of the screen, but only about 20
percent of its height--holds a title graphic, which serves as a landmark to help you remember where
you are. This is an important function, as HTML documents created using frames can get very
complex very quickly. Road signs like the header graphic in this frame can help you get your bearings.
The top-left frame--which takes up about 20 percent of the horizontal real estate and approximately 30
percent of the screen height--contains a top-level navigation menu, which stays in place wherever you
go on the DevEdge site. Making a selection from this menu moves you to a new information category,
such as the support area or library. This graphic menu also serves as a placeholder, because it shows
the currently selected area as highlighted.
The bottom-left frame--about 20 percent of the screen width and 70 percent of its height--is a list of
text-based hyperlinks that make up the information menu for the currently selected category. A new
text menu is displayed in this frame whenever the user selects a new category from the graphic
category menu in the frame above it.
TIP: Netscape has saved itself a great deal of time and development work by making only the
category-level menus graphic, while using easier-to-create, text-only lists of links for the more
numerous subcategory menus.
Finally, the bottom-right frame--which occupies the majority of the screen area, about 80 percent of its
width and 70 percent of its height--contains all of the actual information displayed on this site. The
information in this window is selected from the category-specific text link menu in the frame to its left.
This site can definitely serve as a template for good frames-based HTML document design for any
information that is hierarchically organized by category.
The CyberDungeon
Frames aren't just for business documents. Take a look at Figure 12.2, which depicts the online
CyberDungeon adventure game at http://www.cyberdungeon.com.
You will probably never find 10 frames used as gracefully as those on this site. (Usually it's bad
practice to use more than four to six frames at a time.) This artfully done Web site anticipates the
recent mantra of both Microsoft and Netscape, who are now encouraging developers to use HTML to
create graphical user interfaces for application programming.
The CyberDungeon site uses a set of frames down the left side of the screen to hold graphical icons of
objects you (the resident adventurer) pick up in your explorations. The top frame of the center set of
three displays the text description of your current location, while the larger frame below it shows a
picture of the same scene. The bottom frame gives you choices to make along the way.
Finally, the tall, right frame keeps the CyberDungeon site's navigational menu handy as you play.
This site provides a wonderful example of how a well-designed HTML document using frames can
replicate applications that previously had to be written in high-level languages like C or C++.
A final example is a wonderful lampoon of the too-ambitious use of frames. The Mondrian Machine
site (http://www.desires.com/2.1/Toys/Mondrian/mond-fr.html) takes the overuse of frames--
normally an ugly and heinous practice--and turns it into an art form. See Figure 12.3.
Clicking a selection in the table shown in Figure 12.3 brings up one of several different Mondrian
Machines. Each, in its own unique way, creates an HTML document composed of a wild collection of
frames that rapidly take over the entire screen. Each frame has no content except a background color,
so the end effect is that of a painting by Mondrian, who became famous for dividing his canvases into
so many colored rectangles.
The effect, though humorous and somehow compelling, shows just how much trouble you can get into
if you overdo the use of frames on your own pages.
Diving in head first, take a look at an entire block of HTML markup code that creates a frame
document of medium complexity:
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="25%,50%,25%">
<FRAME SRC="header.htm">
<FRAMESET COLS="25%,75%">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
<FRAME SRC="footer.htm">
</FRAMESET>
<NOFRAMES>
Your browser cannot display frames.
</NOFRAMES>
</HTML>
This example (Frames1.HTM) produces the frames page shown in Figure 12.4. As you can see, this
HTML code produces four frames. The top frame spans the page and includes a header. There are two
central frames, one for a label on the left, which takes up 25 percent of the screen width, and one for
information on the right, which takes up the remaining space. Another frame fills the entire width of
the bottom of the screen and contains a footer.
Though you won't get into the details for a couple more pages, it's important to note that this document
calls four other HTML documents--header.HTM, label.HTM, info.HTM, and footer.HTM--containing
the actual information displayed in each of the individual frames.
Frames are contained in a structure called a FRAMESET, which takes the place of the BODY container on
a frames-formatted page. An HTML document that contains a FRAMESET definition has no BODY section
in its HTML code, and a page with a BODY section cannot use the <FRAMESET> tag.
CAUTION: If you define a BODY section for a page that you compose with FRAMESET and FRAME
commands, the frame structure is completely ignored by browser programs and none of the content
contained in the frames is displayed. Instead, you only see the content contained in the BODY section.
Because there is no BODY container, FRAMESET pages can't have background images and background
colors associated with them. (Remember, these are defined by the BACKGROUND and BGCOLOR attributes
of the BODY tag, respectively.) However, the HTML files that contain the content for the individual
frames can use background colors and images, since they do use the <BODY> tag.
Make sure you don't accidentally use BODY and FRAMESET within the same HTML document.
NOTE: There is a proposal before the HTML standards body to implement a new type of frame
container called an IFRAME, or inline frame. (It is currently implemented only in the Microsoft Internet
Explorer 4.0 browser and FrontPage 98 page composition programs.) This container defines a named
box inside the BODY of a regular HTML page (not a frameset). An IFRAME would float and be
positionable within a page just like a graphic or other object, but its content could be changed by
clicking links, like a frame. Here's an example of how it would look:
<HTML>
<HEAD><TITLE>IFRAME Example</TITLE></HEAD>
<BODY>
Here's an inline frame <IFRAME name="iframe" width=400 height=500></IFRAME> which
can display either of two text files:
<A target="iframe" href="HiThere.htm">Hi There!</A>
<A target="iframe" href="Hello.htm">Hello.</A>
</BODY>
</HTML>
Clicking the "Hi There." link would display the HiThere.HTM file in the inline frame; clicking the
"Hello." link would display Hello.HTM instead, all without reloading the whole page.
The <FRAMESET></FRAMESET> container surrounds each block of frame definitions. Within the
FRAMESET container you can only have FRAME tags or nested FRAMESET containers.
The <FRAMESET> tag has two major attributes: ROWS and COLS (columns). Here's a fully decked-out
(but empty), generic FRAMESET container:
You can define any reasonable number of ROWS or COLS, or both, but you have to define something for
at least one of them.
CAUTION: If you don't define more than one row or column, browser programs ignore your FRAMES
completely. Your screen is left totally blank. In other words, you can't have a FRAMESET of just one row
and one column--which would just be a single window, anyway. If you've defined at least two of either
ROWS or COLS, however, you can safely omit the other attribute, and a value of 100 percent is assumed
for it.
The value_list in your generic FRAMESET line is a comma-separated list of values that can be
expressed as pixels, percentages, or relative scale values. The number of rows or columns is set by the
number of values in their respective value lists. For example,
<FRAMESET ROWS="100,240,140">
defines a frameset with three rows. These values are in absolute number of pixels. In other words, the
first row is 100 pixels high, the second is 240 pixels high, and the last is 140 pixels high.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
124
Shree M .& N. Virani Science College
Setting row and column height by absolute number of pixels is bad practice, however. It doesn't allow
for the fact that browsers run on all kinds of systems on all sizes of screens. While you might want to
define absolute pixel values for a few limited uses--such as displaying a small image of known
dimensions--it is usually a better practice to define your rows and columns using percentage or relative
values, like this:
<FRAMESET ROWS="25%,50%,25%">
This example would create three frames arranged as rows, the top row taking up 25 percent of the
available screen height, the middle row 50 percent, and the bottom row 25 percent.
TIP: Don't worry about having to do the math just right--if the percentages you give for the ROWS or
COLS attribute don't add up to 100 percent, they will be scaled up or down proportionally to equal 100
percent.
The asterisk (*) is used to define a proportional division of space. Each asterisk represents one piece of
the overall pie. You get the denominator of the fraction by adding up all the asterisk values (if there is
no number specified, 1 is assumed). In this example, with an overall pie that has six slices, the first
column would get 1/6 of the total width of the window, the second column would get 2/6 (or 1/3), and
the final column would get 3/6 (or 1/2).
Remember that bare numeric values assign an absolute number of pixels to a row or column, values
with a percent symbol assign a percentage of the total width (for COLS) or height (for ROWS) of the
display window, and values with an asterisk assign a proportional amount of the remaining space.
This example assigns the first column an absolute width of 100 pixels. The second column gets 25
percent of the width of the entire display window, whatever that is. The third column gets 1/3 of what's
left, and the final column gets the other 2/3.
So what are the space-allocation priorities? Absolute pixel values are always assigned space first, in
order from left to right. These are followed by percentage values of the total space. Finally,
proportional values are divided based upon what space is left.
CAUTION: Remember, if you do use absolute pixel values in a COLS or ROWS definition, keep them
small so you are sure they'll fit in any browser window, and balance them with at least one percentage
or relative definition to fill the remainder of the space gracefully.
If you use a FRAMESET with both COLS and ROWS attributes, it creates a grid of frames. Here's an
example:
This line of HTML creates a frame grid with three rows and two columns. The first and last rows each
take up 1/4 of the screen height, and the middle row takes up half. The first column is 2/3 as wide as
the screen, and the second is 1/3 the width.
<FRAMESET></FRAMESET> sections can be nested inside one another, as shown in your initial example,
but don't get ahead of yourself. You need to look at the <FRAME> tag first.
The <FRAME> tag defines a single frame. It must sit inside a FRAMESET container, like this:
Note that the <FRAME> tag is not a container so, unlike FRAMESET, it has no matching end tag. An entire
FRAME definition takes place within a single line of HTML code.
You should have as many <FRAME> tags as there are spaces defined for them in the FRAMESET
definition. In this example, the FRAMESET established two rows, so you needed two <FRAME> tags.
However, this example is very, very boring, since neither of your frames has anything in it! (Frames
like these are displayed as blank space.)
The <FRAME> tag has six associated attributes: SRC, NAME, MARGINWIDTH, MARGINHEIGHT, SCROLLING,
and NORESIZE. Here's a complete generic FRAME:
The most important FRAME attribute is SRC (source). You can (and quite often, do) have a complete
FRAME definition using nothing but the SRC attribute, like this:
<FRAME SRC="url">
SRC defines the frame content's URL. This is usually an HTML format file on the same system (paths
are relative to the page containing the FRAMESET), so it usually looks something like:
<FRAME SRC="sample.htm">
Note that any HTML file called by the SRC attribute in a FRAME definition must be a complete HTML
document, not a fragment. This means it must have HTML, HEAD, and BODY containers, and so on. For
example, the file called by the SRC attribute in this example, sample.HTM, might look like this:
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
This is some Sample Text.
</BODY>
</HTML>
Of course, SRC can point to any valid URL. If, for example, you wanted your frame to display a GIF
image that was located somewhere in Timbuktu, your FRAME might look like this:
<FRAME SRC="http://www.timbuktu.com/budda.gif">
If you specify an URL the browser can't find, space is allocated for the frame, but it won't be displayed
and you get a nasty error message from your browser. Note the effect is quite different than simply
specifying a FRAME with no SRC at all. <FRAME> is always created, but left blank; <FRAME
SRC="unknown URL"> is not created at all--the space is allocated and left completely empty. The
former fills with background color, while the latter remains the browser's border color.
CAUTION: Plain text, headers, graphics, and other elements cannot be used directly in a FRAME
document. All the content must come from the URL defined by the SRC attribute of the <FRAME> tags.
If any other content appears on a FRAMESET page, it is displayed and the entire set of frames is ignored.
"All of this is well and good," you say, "and I really, really want to use frames in my HTML
documents. But I can't help feeling guilty about all those users who don't have frames-capable
browsers. They won't be able to see my beautiful pages!"
Don't worry. Here's where you can provide for them, too.
The <NOFRAMES></NOFRAMES> container saves the day. By defining a NOFRAMES section and marking it
up with normal HTML tags, you can provide alternate information for those without frames-capable
browsers. This is how it works:
<NOFRAMES>
All your alternate HTML goes here.
</NOFRAMES>
You can safely think of this as an alternative to the BODY structure of a normal HTML page. Whatever
you place between the <NOFRAMES> and </NOFRAMES> tags appears on browsers without frames
capability. Browsers with frames throw away everything between these two tags.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
127
Shree M .& N. Virani Science College
NOTE: If you want to include background graphics or images, you can add the <BODY> tag to your
alternate content like this:
<NOFRAMES>
<BODY BGCOLOR="red" BACKGROUND="bgimage.gif">
content...
</BODY>
FIG. 12.3
The Mondrian Machine serves as both a fun Web toy and a graphic illustration of what can happen if
you go too crazy with frames!
</NOFRAMES
As long as the BODY container is kept within the bounds of the NOFRAMES container, your document
works just fine. But there's no need to use the <BODY> tag within the NOFRAMES container unless you
want to take advantage of its special attributes.
The simplest possible frame setup is one with two frames, like this:
<HTML>
<HEAD>
</HEAD>
<FRAMESET COLS="*, 2*">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
</HTML>
This HTML code (2Frames.HTM) defines a page with two frames, organized as two columns. The first
column takes up 1/3 of the width of the screen and contains the HTML document label.HTM, and the
second takes up the other 2/3 and contains the document info.HTM. Figure 12.5 shows how Netscape
Navigator displays this page.
You could just as easily create 10 or more columns, or use the same syntax, substituting the ROWS
attribute to create 2 (or 10) rows. However, 10 columns or rows is way too many for any browser to
handle gracefully. Your pages should probably never have more than three or four rows or columns.
NOTE: If you want to display more information than three or four rows or columns, you should
probably be using tables rather than frames. Remember, frames are most useful when you want to add
an element of control in addition to formatting the display, or if you need to update displayed data
dynamically. Tables are best if all you want to do is format static data into rows and columns.
Too many frames can actually crash your browser. For a real-world example (if you don't mind your
browser program crashing) check out http://www.newdream.net/crash/ (see Figure 12.6).
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="*, 2*" COLS="20%, 30%, 40%">
<FRAME SRC="labela.htm">
<FRAME SRC="labelb.htm">
<FRAME SRC="labelc.htm">
<FRAME SRC="infoa.htm">
<FRAME SRC="infob.htm">
<FRAME SRC="infoc.htm">
</FRAMESET>
</HTML>
This example (2by3Grid.HTM) creates a grid with two rows and three columns (see Figure 12.7).
Because you defined a set of six frames, you've provided six FRAME definitions. Note that they fill in by
rows. That is, the first FRAME goes in the first defined column in the first row, the second frame follows
across in the second column, and the third finishes out the last column in the first row. The last three
frames then fill in the columns of the second row going across.
Also, note that the math didn't work out very well, since the percentage values in the COLS definition
only add up to 90 percent. No problem, because the browser has adjusted all the columns
proportionally to make up the difference.
A bit tougher is the problem of creating a more complex grid of frames. For that, return to the example
that opened this discussion (see Figure 12.4):
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="25%,50%,25%">
<FRAME SRC="header.htm">
<FRAMESET COLS="25%,75%">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
<FRAME SRC="footer.htm">
</FRAMESET>
<NOFRAMES>
Your browser cannot display frames.
</NOFRAMES>
</HTML>
This example (Frames1.HTM) makes use of nested FRAMESET containers. The outside set creates three
rows, with 25 percent, 50 percent, and 25 percent of the window height, respectively:
<FRAMESET ROWS="25%,50%,25%">
Within this definition, the first and last rows are simple frames:
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
129
Shree M .& N. Virani Science College
<FRAME SRC="header.htm">
<FRAME SRC="footer.htm">
Each of these rows runs the entire width of the screen. The first row at the top of the screen takes up 25
percent of the screen height, and the third row at the bottom of the screen also takes up 25 percent of
the screen height.
<FRAMESET COLS="25%,75%">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
This FRAMESET defines two columns that split the middle row of the screen. The row these two
columns reside in takes up 50 percent of the total screen height, as defined in the middle row value for
the outside FRAMESET container. The left column uses 25 percent of the screen width, while the right
column occupies the other 75 percent of the screen width.
The frames for the columns are defined within the set of FRAMESET tags, which include the column
definitions, while the frame definitions for the first and last rows are outside the nested FRAMESET
command, but within the exterior FRAMESET, in their proper order.
This is not as confusing if you think of an entire nested FRAMESET block as a single <FRAME> tag. In
this example, the outside FRAMESET block sets up a situation in which you have three rows. Each must
be filled. In this case, they are filled by a FRAME, then a nested FRAMESET two columns wide, then
another FRAME.
By now (if you are a perverse programming-type person) you may be asking yourself, "I wonder if it is
possible for a FRAME to use as its SRC a document that is, itself, a FRAMESET?" The answer is "Yes." In
this case, you simply use the <FRAME> tag to point to an HTML document that is the FRAMESET you
would have otherwise used in place of the FRAME.
Redefine the previous example (which used nested FRAMESETs) in terms of referenced FRAME
documents instead. All you're doing is moving the nested FRAMESET to its own document. Here's the
first (outside) file (Frames2.HTM):
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="25%,50%,25%">
<FRAME SRC="header.htm">
<FRAME SRC="nested.htm">
<FRAME SRC="footer.htm">
</FRAMESET>
<NOFRAMES>
Your browser cannot display frames.
</NOFRAMES>
</HTML>
In this case, the top and bottom rows behave as before. But the second row in the "outside" file is now
just a simple FRAME definition like the others. However, the "inside" file that its SRC points to is
Frameset.HTM, which you created with a FRAMESET all its own. When inserted into the original
FRAMESET, it behaves just as if it appeared there verbatim. The resulting screen is identical to the
original example (compare Figure 12.8 to Figure 12.4).
CAUTION: Though it's possible to create nested FRAMESETs by using <FRAME> tags that call the same
URL, it certainly isn't a good idea. This is called infinite recursion, which creates an infinite loop in a
computer that consumes all memory and crashes the machine. Fortunately, frames-aware browsers
check for this--if an SRC URL is the same as any of its ancestors it's ignored, just as if there were no
SRC attribute at all.
By using nested FRAMESET containers in clever combinations, it is possible to create just about any grid
of frames you can dream up. But remember that you're trying to create a friendly, useful interface, not
show off how clever you can be with frames.
NOTE: In Netscape Navigator 2.0, the toolbar's Back button didn't back you out of a frame, it backed
you out of the whole FRAMESET to the previous page.
With versions 3.0 and above--as well as within Internet Explorer--pressing the Back button returns you
to the previous state of the currently selected frame.
To navigate forward or backward within a frame, make sure you make the frame active first by
clicking in it somewhere, then use the Forward or Back buttons or menu selections to navigate within
that frame.
Now that you understand how framesets are used to create various grids of frames, take a look at some
of the attributes that modify how frames look and feel.
Frame Margins
The FRAME attributes MARGINWIDTH and MARGINHEIGHT give you control over the width of the frame's
interior margins. They both look like this:
MARGINWIDTH="value"
value is always a number, and always represents an absolute value in pixels. For example:
would create a frame with top and bottom interior margins five pixels wide, and left and right margins
seven pixels wide. Remember, you're talking interior margins here, not borders. MARGINWIDTH and
MARGINHEIGHT define a space within the frame within which content will not appear. Border widths are
set automatically by the browser, or by the BORDER attribute, which is discussed later in this chapter in
the "Frame Borders" section.
Frame Scrollbars
Your frames will automatically have scrollbars if the content you've specified for them is too big to fit
the frame. Sometimes this ruins your page's aesthetics, so you need a way to control them. That's what
the SCROLLING attribute of the <FRAME> tag is for. Here's the format:
<FRAME SCROLLING="yes|no|auto">
There are three valid values for SCROLLING: Yes, No, and Auto. Auto is assumed if there is no
SCROLLING attribute in your FRAME definition. Yes forces the appearance of a scrollbar. No keeps a
scrollbar away at all costs. For example, this FRAME definition turns on scrollbars:
<FRAME SCROLLING=YES>
Frame Resizing
Frames are normally resizable by the user, but if you let the user drag your frames around, it can
quickly muck the look and feel of your beautifully designed frames. Therefore, you almost always
want to use the NORESIZE attribute of the <FRAME> tag to keep users from resizing your frames. Here's
how:
<FRAME NORESIZE>
That's it. No values. Of course, when you set NORESIZE for one frame, none of the adjacent frames can
be resized, either. Depending on your layout, using NORESIZE in a single frame will often be enough to
keep users from resizing all the frames on the screen.
When you move over a resizable frame border with the mouse cursor, it changes to a double-arrow
(see Figure 12.9), indicating that the frame can be resized. If you don't get the double-arrow, it means
that resizing has been turned off with the NORESIZE attribute. To resize a resizable frame, grab the
frame border by clicking and dragging it with your mouse to a new position.
TROUBLESHOOTING: I've created a frame using the NORESIZE attribute. What do I do about users
who are using small screens on which the entire contents of the frame may not fit? Your best bet is to
make sure the frame will hold all of its content at lower screen resolutions. That is, redesign the frame.
Otherwise, consider reenabling, resizing, or adding scrollbars to the frame.
Frame Borders
You use the BORDER, FRAMEBORDER, and BORDERCOLOR attributes to set the look and feel of the borders
for your frameset.
The BORDER attribute is used only with the <FRAMESET> tag, and sets the width of all the borders in the
frameset. It is assigned a value in pixels, like this:
<FRAMESET BORDER="5">
This example would set the width of the frame borders to 5 pixels. BORDER can be assigned a value of
0, in which case all the frames in your frameset will be borderless.
TIP: The default value of BORDER (that is, the value it assumes if there is no BORDER="n" attribute
specified for a given FRAMESET) is 5.
The FRAMEBORDER attribute can be used with either the <FRAMESET> or <FRAME> tag. It has two
legitimate values, YES and NO. If FRAMEBORDER="YES", then frame borders are drawn with a 3-D look.
If FRAMEBORDER="NO", frame borders are invisible, which really means that they are drawn in the
default background color of the browser.
The default value of FRAMEBORDER is YES, which means that browser programs generally display 3-D
frame borders.
The border for a frame will be invisible (not 3-D) only if FRAMEBORDER="NO" is set for all surrounding
frames.
TIP: To create a page with entirely borderless frames, set FRAMEBORDER="NO" and BORDER="0" in the
top FRAMESET definition.
The BORDERCOLOR attribute can be used with the FRAMESET tag or with the FRAME tag. BORDERCOLOR
can be assigned a named color value, or a hexadecimal RGB color value. Here's an example:
In this example, the outer <FRAMESET> tag sets the BORDERCOLOR to red, one of the named colors for
most browsers. But the following <FRAME> tag sets BORDERCOLOR to the hexadecimal value #FF00FF
NOTE: RGB hexadecimal color values are precise, but obscure. (Exactly what color is #FA10D7?)
Named colors are easier to comprehend, but not all browsers support the same color names. In general,
if you stick with the sixteen common color names listed here, you'll be safe: aqua, black, blue, fuchsia,
gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow.
TIP: If two adjacent frames of the same priority attempt to define their own BORDERCOLOR, neither
takes effect. They revert to the BORDERCOLOR defined at the next higher FRAMESET level.
Figure 12.10 shows an example of using the BORDER, FRAMEBORDER, and BORDERCOLOR attributes to
control the look and feel of your frame borders. Note that the only frame to maintain the BORDERCOLOR
defined in the outside FRAMESET definition is the one in the upper-right, the only frame that doesn't
share a border with the leftmost center frame, which redefines the BORDERCOLOR. Actually, the
rightmost center frame would have also had a red border on the left, but it has had its left border turned
off by the FRAMEBORDER="NO" attribute it shares with the central frame. Note this complex interplay of
attributes carefully. If you use them often, their interrelationships are sure to throw you for a loop more
often than they make sense.
CAUTION: Microsoft Internet Explorer supports one more attribute for FRAMESET, called
FRAMESPACING. It is intended to define the space between frames, and can assume pixel values.
However, because Netscape Navigator and other browser programs don't support the FRAMESPACING
attribute, you are strongly advised against using it unless you are creating content for an audience that
uses Internet Explorer exclusively, and you have a good reason for having to specify the spacing
between frames.
NOTE: There are two more attributes for the <FRAME> tag: ONLOAD and ONUNLOAD. These are used with
scripting languages like VBScript and JavaScript to specify a script to run when a frame is loaded or
unloaded from a frameset. Scripting is covered in detail in Chapter 16, "Adding JavaScript and
VBScript to HTML."
Targeted Hyperlinks
Though you've examined in-depth how to create and nest framesets, and how to control the look and
feel of frames, you have yet to understand how to use frames to control navigation, which is its major
application. To use frames to their full advantage, you need to know how to name and target frames.
The NAME attribute assigns a name to a frame that can be used to link to the frame, usually from other
frames in the same display. This example,
creates a frame named "Joe," which can be referenced via a hyperlink like this:
Note the TARGET attribute in the hypertext link that references the name of your frame. When selected,
this hyperlink replaces the content of the named frame "Joe"--which was given the content file
info.HTM when it was created--with the content in the file moreinfo.HTM. Note that while a hyperlink
without a named TARGET replaces the content in its own window or frame with the content named in
the HREF attribute, a hyperlink with a named TARGET instead replaces the content in the targeted frame
or window with the content named in the HREF attribute. This is the only trick you need to know for
creating killer frames-based navigational systems. Of course, there are some fine points.
Legitimate Names
If you don't create an explicit name for a frame, it simply has no name, and you won't be able to use
links in one frame to open documents or images in another. You'll want to name all frames whose
content will be changed by clicking a link in a different frame.
All frame names must begin with an alphanumeric character. Don't use an underscore (_) as the first
character in a frame name. Other than that, you're pretty much on your own.
However, there are four reserved implicit names built into HTML, and all of them do start with an
underscore. These are listed in Table 12.1. All other names starting with an underscore are ignored.
Name Purpose
_blank Load content directed to this name into a new, unnamed window. This name is used to
completely wipe out the current frameset and start with a new, blank window.
_self Load content directed to this name into the calling frame.
_parent Load content directed to this link to the calling frame's parent frameset window. If it has no
parent frameset, this is the same as using the name _self.
_top Load content directed to this link to the top level frameset related to the calling frame. If the
calling frame is already the top level, this is the same as using the name _self.
Here are a few examples to help clarify how these reserved names work.
If a frame contains the following link, then clicking the link launches a new, unnamed browser display
window that contains the content defined in stuff.HTM. This can be a simple HTML document, or an
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
135
Shree M .& N. Virani Science College
entirely new FRAMESET definition. Whichever, this call wipes the slate clean and starts completely
over.
If a frame contains the following link, then clicking the link will simply cause the frame which
contains the link to clear, and its content will be replaced with whatever is in stuff.htm.
If a frame contains the following link, the frameset that contains the frame that contains this link will
be replaced by stuff.HTM.
Finally, if a frame contains the following link, clicking the link replaces the entire browser window
with the contents of stuff.HTM.
NOTE: Hyperlinks using the <A> or anchor tag aren't the only tags that can make use of the TARGET
attribute. The <AREA>, <FORM>, and <BASE> tags also use the TARGET attribute, and can be used
effectively to extend and expand the utility of named frames.
Remember, too, that windows can also be named by using the TARGET attribute within the <A> tag;
using named windows in conjunction with named frames adds a whole new dimension to HTML
document navigation.
You've seen that you can click a link in one frame to change the content in another. First you name the
target frame using the NAME attribute of the <FRAME> tag when creating the target frame. You then use
the TARGET attribute of the <A> hyperlink tag when defining the link, as in this example:
The first line of HTML is used in the frame definition document, and the second line is used in the
document that links to the first.
You've also seen that you can use special implicit names to target some frames and framesets,
depending on their relationship to the frame that contains the calling link.
But what if you want to update more than one frame by clicking a single link? This is possible if you
set up your document correctly. The key is to update a frameset, not a single frame.
To do this, create a subframeset that is contained in its own file, as was done earlier in the example
shown in Figure 12.8. If you recall, you began with an HTML document that included one frameset
nested inside another:
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
136
Shree M .& N. Virani Science College
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="25%,50%,25%">
<FRAME SRC="header.htm">
<FRAMESET COLS="25%,75%">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
<FRAME SRC="footer.htm">
</FRAMESET>
</HTML>
Then you took the nested frameset out and put it into its own file.
Here's the original file, with the nested frameset replaced by the FRAME definition pointing to the
second file, nested.HTM. Note that you named this frame this time using the NAME attribute, calling it
"Inner":
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="25%,50%,25%">
<FRAME SRC="header.htm">
<FRAME SRC="nested.htm" NAME="Inner">
<FRAME SRC="TestLink.htm">
</FRAMESET>
</HTML>
Also note the last FRAME SRC file has been renamed TestLink.HTM--this file contains the targeted link
you want to test. Call this modified file NameTest.HTM. Now here's the file (nested.HTM) that the
frame named Inner calls:
<HTML>
<HEAD>
</HEAD>
<FRAMESET COLS="25%,75%">
<FRAME SRC="label.htm">
<FRAME SRC="info.htm">
</FRAMESET>
</HTML>
The file that occupies the bottom frame contains the file TestLink.HTM, which is listed here:
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<A HREF="NewStuff.htm" TARGET="Inner">Click me</A>
to put new stuff into the upper center frameset.
</BODY>
</HTML>
When the link Click me in the bottom window is clicked, it replaces the two frames in the center
frameset (which was defined in the file nested.HTM) with new information from the document
NewStuff.HTM. Say this is the content of NewStuff.HTM:
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
Here is some NEW STUFF!
</BODY>
</HTML>
When you click the link in the bottom window, you get the result shown in Figure 12.12.
With one click, you've replaced the two frames of the central frameset with a single frame containing
new content. You could just as easily have replaced the two frames with two new frames--the same
size, or different sizes--or with three frames, or with a whole new frameset. All you would have to do
is define the new frameset in your new content file, NewStuff.HTM.
If you're careful and think ahead when defining your framesets, you can easily create hyperlinks that
can update almost any combination of frames with a single mouse click.
TROUBLESHOOTING: I have two frames that don't have the same parent frameset. Can I
update both of them with one hyperlink? Yes. You have to write a JavaScript or VBScript
application to handle them. In fact, this is how Netscape Communications has done multiframe updates
from single hyperlinks on its own Web site.
Chapter 12
Collecting Input with Forms
Forms are one of the most popular, interactive features on the World Wide Web (WWW). They enable
users to interact with the text and graphics that are displayed on your machine. You can make forms
with simple yes or no questions; you can make highly complex order forms; or you can make forms for
people to send you comments.
You create forms by providing a number of fields in which a user can enter information or choose an
option. Then, when the user submits the form, the information is returned to a server-side script. A
script is a short program that is written specifically for each form. You can create scripts to do any
number of things. You can also handle the contents of a form by using a client-side script, which you
learn about in Part VI, "Scripting on the Web Server."
HTML forms give you the opportunity to gather information from people reading your Web page. Just
as HTML provides many mechanisms for outputting information, the use of HTML forms enables
input. These forms can be used to solicit free-form text information, get answers to yes or no questions,
and get answers from a set of options.
You can add forms to your Web page with many different results in mind. You can do something
simple, like asking visitors to sign a guest book or comment about your Web site. You can also use
forms to gather input for a discussion group or, when combined with a secure method of transmission,
take online orders for your $10 widgets. These and many other results can be achieved with HTML
forms.
The HTML tags you use to display forms are straightforward. There are three types of tags for creating
fields: <TEXTAREA>, <SELECT>, and <INPUT>. You can put any number of these tags between the
<FORM> and </FORM> container tags. The following is a brief description of each tag (you'll learn more
about each a bit later in this chapter):
<TEXTAREA> This tag defines a field in which the end user can type multiple lines of text.
<SELECT> This tag enables the end user to choose among a number of options in either a scroll box
or pop-up menu.
<INPUT> This tag provides all of the other types of input: single lines of text, radio buttons, check
boxes, and the buttons to submit or clear the form.
<FORM>
ACTION This attribute points the form to an URL that will accept the form's information and do
something with it. If you don't specify an ACTION, it sends the information back to the same
URL the page came from.
METHOD This attribute tells the form how to send its information back to the script. The most common
method is POST, which sends all the information from the form separately from the URL. The
other option for METHOD is GET, which attaches the information from the form to the end of the
URL.
This example says that you want the browser to send the completed form to the script
comment_script in the cgi-bin directory on your server and to use the POST method to send it.
CAUTION: You can put any number of forms on the same HTML page, but be careful not to nest one
form inside another. If you put in a <FORM> tag before finishing the last one, that line is ignored and all
the inputs for your second form are assumed to go with the first one.
<TEXTAREA>
With <TEXTAREA>, you can provide a field for someone to enter multiple lines of information. By
default, a <TEXTAREA> form shows a blank field four rows long and 40 characters wide. You can make
it any size you want by using the ROWS and COLS attributes in the tag. You can also specify some
default text by simply entering it between the <TEXTAREA> and </TEXTAREA> tags.
TIP: <TEXTAREA> fields are ideal for having users enter comments or lengthy information because
they can type as much as they want in the field.
While the ROWS and COLS attributes are not required, there is no default value for these that you are
guaranteed to get on every Web browser, so it's always a good idea to set them. Listing 13.1 shows you
an example using the <TEXTAREA> tag. Figure 13.1 shows you what this example looks like.
TIP: All input fields in a form--<TEXTAREA>, <SELECT>, and <INPUT>--must each have a NAME defined
for its information.
<SELECT>
The <SELECT> element shows a list of choices in either a pop-up menu or a scrolling list. It's set up as
an opening and closing tag with a number of choices listed in between. Just like the <TEXTAREA>
element, the <SELECT> tag requires you to define a name. You can specify how many choices to show
at once by using the SIZE attribute.
TIP: Some WWW browsers don't properly display a scrolling window if the SIZE is 2 or 3. In that
case, leave it as a drop-down list or think about using the <INPUT> field's radio buttons.
You present the choices the end user can make within the <SELECT> and </SELECT> tags. The choices
are listed inside the <OPTION> tag and don't allow any other HTML markup.
Consider Listing 13.2, the results of which are shown in Figures 13.2 and 13.3. This HTML adds a list
called network to the document that contains four options: ethernet, token16, token5, and localtalk.
Suppose you set the tag as shown in Listing 13.3, the result of which is shown in Figure 13.4.
TROUBLESHOOTING: I know the most common choices I want to present, but I want to allow
people to enter their own value if they want to. How can I do that? Your best bet is to display the
common choices in a <SELECT> box or pop-up menu, with one of the options set to Other. Then
include an <INPUT> text field or a <TEXTAREA> field right after the list of choices (see Listing 13.4).
TIP: You can use the <SELECT> tag as a navigational aid in your Web pages. You can provide a
number of URLs in a list. The user can then choose one, click a Submit button, and have the server-
side or client-side script jump to the URL indicated by that choice. Microsoft uses this method to direct
users to different international Web sites (see http://www.microsoft.com).
<INPUT>
<INPUT>, unlike <TEXTAREA> and <SELECT>, is a single tag option for gathering information. <INPUT>
contains all of the other options for acquiring information, including simple text fields, password
fields, radio buttons, check boxes, and the buttons to submit and reset the form.
NAME This defines the name for the data. This field is required for all the types of input except
Submit and Clear.
SIZE This is the size of the input field in number of characters for text or password.
MAXLENGTH This specifies the maximum number of characters to be allowed for a text or password
field.
VALUE For a text or password field, it defines the default text displayed. For a check box or radio
button, it specifies the value that is returned to the server if the box or button is selected.
For the Submit and Reset buttons, it defines the text inside the button.
CHECKED This sets a check box or radio button to on. It has no meaning for any other type of
<INPUT> tag.
TYPE This sets the type of input field you want to display. (See the types in the following
section.)
TROUBLESHOOTING: I want to let someone put in a very long URL, but the screen is not wide
enough. How do I do that? A good way to enable someone to put in an extremely long text line is to
simply set the size to 60 or 80 characters and not set a maximum length. This allows a user to put in a
very long string, even if you can't see it all at once.
PASSWORD PASSWORD, a modified TEXT field, displays typed characters as bullets instead of the
characters actually typed. Possible attributes to include with the type PASSWORD include NAME
(required), SIZE, MAXLENGTH, and VALUE. Consider Listing 13.6, the result of which is shown in Figure
13.7.
CHECKBOX CHECKBOX displays a simple check box that can be checked or left empty; use a check
box when the choice is yes or no and doesn't depend on anything else. Possible attributes to include
with the TYPE text include NAME (required), VALUE, and CHECKED (which defaults the check box as
checked). Consider Listing 13.7, the result of which is shown in Figure 13.8. Check boxes are useful
when you have a list of options, more than one of which can be selected at a time.
CAUTION: You want to be especially careful when using check boxes and radio buttons in HTML
documents with custom backgrounds or background colors. Depending on the Web browser used,
check boxes and radio buttons sometimes do not show up with dark backgrounds.
RADIO RADIO is a more complex version of a check box, allowing only one of a related set to be
chosen. You can group radio buttons together by using the NAME attribute; this keeps all buttons in the
same group under one NAME. Possible attributes to include with the TYPE text include NAME (required),
VALUE, and CHECKED. Consider Listing 13.8, the result of which is shown in Figure 13.9.
Listing 13.9 is a variation on Listing 13.8. The result is shown in Figure 13.10.
TIP: If you want to provide a long list of choices, use the <SELECT> tag so the choice doesn't take up
as much space on the page.
CAUTION: If you don't specify a set of radio buttons or check boxes with one of the values as
CHECKED, then you could receive an empty field for that <INPUT> name.
RESET RESET displays a push button with the preset function of clearing all the data in the form to its
original value. You can use the VALUE attribute with the RESET tag to provide text other than Reset (the
default) for the button. For example, consider Listing 13.10. The result is shown in Figure 13.11.
SUBMIT SUBMIT displays a push button with the preset function of sending the data in the form to the
server to be processed by a server-side script. You can use the VALUE attribute with SUBMIT to provide
text other than Submit Query (the default) for the button. Consider, for example, Listing 13.11. The
result is shown in Figure 13.12.
Forms can be easy to read, simple one- or two-entry affairs with little to display; they can also be
terrifically complex devices. As your forms get more complex, you need to carefully consider their
layout. Think about how to make it obvious that certain titles are connected to certain fields and think
about how to make your forms easy for anyone to use. People are often put off by complex forms that
are hard to understand, so it's in your best interest to make them easy and fun to use--regardless of their
complexity.
When you markup HTML documents, you usually just let the words wrap across the screen. Although
this flexibility is wonderful to have for segments of text, it can make reading a form incredibly
difficult. A quick and simple solution is to include the line break tag, <BR>, to move something to the
next line.
Forcing Fields onto Separate Lines If you want to have two fields, Name and E-Mail Address, for
example, you can simply mark them up as shown in Listing 13.12.
Although this might look great now, it can wrap strangely on some WWW browsers and look shabby
when displayed (see Figure 13.13).
To split these lines and make them more readable, you need to include the line break tag, <BR>,
between them, as shown in Listing 13.13.
Adding the <BR> tag between the two fields forces the browser to wrap the field to the next line,
regardless of the width of the screen. The result of Listing 13.13 is shown in Figure 13.14.
NOTE: The wrapping feature of HTML can work for you to help keep a form small in size. If you
have several multiple-choice items that could take up huge amounts of space on your form, you can try
to keep them small and let them wrap closely together on the page.
If you're using the <SELECT> tag, the width of the pop-up menu on the screen is directly related to the
words in the options to be selected. If you keep all the words small, you can provide a relatively large
number of choices in a small area.
Working with Large Entry Fields If you're working with long text entry fields or perhaps with a
<TEXTAREA> field, it's often easier to put the text just above the field and then separate the different
areas with paragraph breaks. For example, if you have a text input line that is very long or a long field
description, it doesn't work well to put them side by side. Also, if you want to leave a space for
comments, it's easier--and looks nicer--to have the field description just above the comment area. This
makes it appear that there's more space to write in. Listing 13.14 is an example of this sort of design.
The result of this code is shown in Figure 13.15.
NOTE: Most browsers automatically wrap a large field to the next line, treating it like an image.
Because you don't know how wide (or narrow!) the client screen is, take steps to ensure the form will
look as you want. If, for example, you want the field to be on the next line, put in a <BR> tag to make
sure it will be!
CAUTION: If you're using the <PRE> tags to line up fields, don't use any other HTML tags inside that
area. Although the tags won't show up, they'll ruin the effect of lining everything up perfectly.
CAUTION: Make sure you keep the size of the fields smaller than the general browser, or your lines
will wrap off the screen. If an input field has to be large, you can use a line break to put the field on its
own line.
Using HTML Tables to Line Up Forms Another way to line up form fields is to place them in an
HTML table. This can produce an effect similar to using preformatted text but, because you are using
regular HTML rather than preformatted text, you can also include other HTML constructs within the
form. So, by using a table rather than preformatted text to align your form, you're also able to include
images, hypertext links, or other HTML elements as part of the form. Listing 13.17 is an example of
the entry form shown in Figures 13.16 and 13.17, formatted using an HTML table. The result of this
code is displayed in Figure 13.18.
TIP: Some people use browsers, particularly text-only ones, that don't support tables. If you use tables
with your forms, consider including an alternate page without tables for these folks. See Chapter 11,
"Formatting Content with Tables," for alternatives for browsers that don't support tables.
Using Paragraph Marks to Separate Form Sections If you have a large form with different
sections, it's handy to separate those sections. The paragraph container tag, <P>...</P>, provides a
way of adding some space without making the delineation so hard that it appears to be another form.
For example, a simple comment form might have places for a name and an e-mail address, but these
might not be a required part of the form. In this case, separate the comment part of the form from the
area that's optional. It's also possible to make it more obvious by simply making some comments in the
form, such as a small heading titled Optional. A simple comment form with optional Name and E-Mail
fields can have the code shown in Listing 13.18.
There are a few occasions when line breaks and paragraph tags can't set up the form exactly as you'd
like. At these times, list tags can provide just the right look! The best use of list tags is for indenting
and numbering text.
Indenting Form Entries with Descriptive Lists On the WWW, it's common to see order forms for
merchandise. Finding the method of payment is a perfect use for descriptive list tags to lay out the
choices. Indenting some items more than others makes the options obvious and easy to read.
NOTE: When you lay out lists, consider indenting the areas in your HTML documents that will be
indented on-screen. This makes it easier to remember to finish with the descriptive list tag, </DL>.
Using Ordered Lists to Number Fields It's easy to display a numbered list if you use the ordered list
tag, <OL>. Listing 13.20 uses the <OL> tag to automatically number the fields. The result of this code is
shown in Figure 13.21.
Check boxes and radio buttons can provide a great deal of simple yes or no input. They can also be
some of the hardest parts of a form to understand if they're not laid out correctly. There are three
straightforward methods of layout: setting up the check boxes and radio buttons in a line horizontally,
using a list to order them vertically, or setting them up in a grid pattern.
Setting Up Check Boxes or Radio Buttons in a Line Probably the easiest method of layout is listing
the check boxes in a line horizontally (see Listing 13.21). It has the benefits of being very simple to set
up, relatively compact on the browser, and easy to understand. The only caution is to make sure there
aren't too many items for one line. The intent of the form might not be obvious if you let check boxes
wrap unintentionally. The result of Listing 13.21, which specifies a horizontal line of radio buttons, is
shown in Figure 13.22.
TIP: When creating a Web page with a line of buttons, check it with your Web browser set to the
width of a 640x480 screen to make sure your line doesn't wrap.
Lists of Check Boxes When the choices get more complex than a simple line selection, it's best to
forgo compactness and spread out the choices in a list, as specified in Listing 13.22. The result of using
a descriptive list in this code is shown in Figure 13.23.
It's quite possible to put multiple forms in a single document; it often makes the document more
concise and easier to understand. An example of using multiple forms is a document with a number of
different methods for searching. From one form, you can choose to do a search from any of a number
of locations by having each <FORM> point to a different search method.
TIP: Also consider using multiple forms when your form is too large to fit on one or two screens; this
makes it easier for your readers to use the form.
When including multiple forms in a document, visibly separate them to make them easier to
understand. A common way to break up a form is to use the horizontal rule tag, <HR>, or a wide image
that looks like a horizontal rule in an <IMG> tag. Put line breaks before and after the tags. For example,
Listing 13.24 shows how to separate three forms by using <HR> tags to break them up. The result of
this code is shown in Figure 13.25.
TROUBLESHOOTING: I put two forms in one document, but I only see one. Why aren't both
showing up? Check to make sure you finished one form before beginning another. If you didn't
include the </FORM> tag to stop the first form, the second <FORM> tag is just ignored.
As discussed earlier in this section, forms can be used very effectively with HTML tables, allowing
more control of the positioning of different fields. Listing 13.25 shows an address entry form that uses
a table to align the different fields. The resulting Web page is shown in Figure 13.26.
This idea can be taken even further, including other form elements such as check boxes or radio
buttons, to allow the user more input options. A further refinement of the address entry form, allowing
the user to input both a home and business address and specify which is preferred, is shown in Listing
13.26--the corresponding Web page is shown in Figure 13.26.
One final refinement of the address entry form (see Figure 13.28) substitutes different submit buttons
for the radio buttons, shown in Figures 13.26 and 13.27. This allows the user to enter the information
on the form and then specify which is the preferred address by his choice of submit button. Specifying
a NAME attribute for the submit button enables the choice of button to be determined, as shown in
Listing 13.27.
When you're creating forms, it's always a good idea to keep the form on a single page. Further, because
you can't control what browser someone uses to look at your pages, you need to observe some general
guidelines, as follows:
• If your form is very short, keep it under 14 lines. This ensures that it will fit on one page in
most browsers. It doesn't always work, but it does create a compact page that's easy for most
people to see. A good trick for keeping the pages compact is using <SELECT> tags with the size
set to 1 (to show a pop-up menu) or 3 or 4 (for a small scrolling window for multiple choices)
instead of having large numbers of check boxes and radio buttons.
• If your form is large (more than two pages on any browser), don't put the Submit or Reset
buttons in the middle of the form. If you do, someone reading the form might not continue
beyond those buttons and miss an important part of the form.
• Put the fields on your form in a logical order. This sounds obvious, but it's easy to forget.
• Think about your forms well before you start creating them. If you know what choices you
want to provide, it makes your final layout much easier.
As useful as HTML forms have been, they have suffered from a variety of shortcomings and
limitations, ranging from a lack of hotkey support to their reliance on only two control buttons. With
the release of the HTML 4.0 specification, all that has changed. Just about every feature requested by a
feature-hungry public has been added to HTML 4.0 forms.
NOTE: As of this writing, the HTML 4.0 specification is brand new and neither Netscape
Communicator nor Microsoft Internet Explorer support the all-new forms tags or attributes discussed
in this section. So not only can't we show you example screens, we're also passing along a caution not
to use these new tags and attributes until these browser programs add support for them.
ACCESSKEY is a new attribute for use with the LABEL, A, and CAPTION tags. With it, you can define a
single case-insensitive hotkey for activating a forms element. For example,
The new DISABLED attribute for INPUT, TEXTAREA, SELECT, OPTION, OBJECT, LABEL, and BUTTON turns
off an element and grays it out on the screen. (The element is also skipped when tabbing between
elements.) It should be used when a form element is currently inappropriate or if you want to skip a
field for some reason. Once DISABLED, the only way to turn an element back on is by using an
associated script, such as JavaScript.
NOTE: It is not immediately clear in the HTML 4.0 specification just exactly what you need to do to
make such changes dynamically via a script. Hopefully this will become known as HTML 4.0 is
implemented in the major browsers.
The TEXTAREA tag and the INPUT tag's TEXT and PASSWORD types have a new READONLY attribute that
can be used to prohibit user input in those fields. If you want to pass back some data that you've preset
for a user, this is one way to do it. At the same time, you're making sure that data is known to the end
user but is not modifiable by him. Again, you can use a script to change this state dynamically if you
wish.
ONCLICK, ONFOCUS, ONBLUR, ONSELECT, and ONCHANGE are new attributes that function as placeholders
for scripts that run when each of the indicated events occurs. The ONCLICK script runs when a mouse
click occurs over an element, ONFOCUS when it becomes the input focus, ONBLUR when the focus moves
away from the element, ONSELECT when chosen, and ONCHANGE when data in the field has changed.
These exciting new attributes open up a world of new possibilities. Again, the specifics of their
implementation await browsers that can interpret these new attributes.
Ever wanted to add those nifty pop-up ToolTips to your online forms? Now you'll be able to, thanks to
the new TITLE attribute, which is available for use with all form input elements. Just specify
TITLE="ToolTip Here" for any element.
Under HTML 3.2, there was no specified order for tabbing through elements. You hit the Tab key and
the form's input focus advanced to whatever element was next in line by virtue of where it appeared in
the HTML source. Unfortunately, that didn't always correspond to how those elements were arranged
on the page. Now, thanks to the new HTML 4.0 TABINDEX attribute, that's going to change. It's easy to
add--just add TABINDEX=n to each element, where n is equal to its place in the tabbing sequence. n
must be an integer, but it can also have a negative value, which indicates that the element should be
left out of the tabbing sequence. If two elements have the same TABINDEX value, they are assigned a
tabbing sequence based on their order in the HTML source. Likewise, elements without a TABINDEX
value are inserted into the sequence based on their source positions. As with HTML 3.2 forms,
Shift+Tab moves the focus backwards through the order. Also, the Enter key is still used to activate an
element that has the current focus.
The new LABEL tag is used to associate a label with a form element. It is useful for creating a user
interface for selecting a form control. For example,
<LABEL FOR=NAME>Name</LABEL>
Lots of stuff goes here...
<INPUT TYPE=TEXT NAME=YOURNAME ID=NAME>
Clicking the NAME link in the LABEL will jump the end user to the text input field with the ID of NAME,
as indicated by the FOR=NAME attribute of the LABEL tag, and will shift the focus to that field.
The LABEL element supports the use of the ID, CLASS, LANG, and DIR attributes for internationalization
and access for those with disabilities, and also makes use of the STYLE attribute for accessing style
sheets. The new TITLE, DISABLED, ACCESSKEY, ONCLICK, ONFOCUS, and ONBLUR attributes discussed in
the previous section are also all supported by LABEL.
HTML 3.2 forms supported only the Submit and Reset buttons. HTML 4.0 forms improve on this with
a user-definable BUTTON element. The BUTTON tag works in conjunction with the new ONCLICK
attribute, which associates clicking the button with executing a script. The DISABLED, TABINDEX,
ONFOCUS, and ONBLUR attributes are also supported by BUTTON. <BUTTON> is a container, so it must be
used with an associated </BUTTON> tag. In between, you can include any HTML to define the button
contents, as in this example:
<BUTTON ONCLICK="script.scp">
<IMG SRC="ButtonImage.gif">
Click this button to do something great!
</BUTTON>
Finally, the new FIELDSET container is used in conjunction with a new CAPTION container to group
form elements, as in this example:
<FIELDSET>
<CAPTION ACCESSKEY=N TABINDEX=1>Name Fields</CAPTION>
<LABEL ACCESSKEY=F><INPUT TYPE=TEXT NAME=FirstName>First Name</LABEL><BR>
<LABEL ACCESSKEY=L><INPUT TYPE=TEXT NAME=LastName>Last Name</LABEL>
</FIELDSET>
Note that the CAPTION container is used to define a tab order (via the TABINDEX attribute) for the entire
FIELDSET group. Likewise, the FIELDSET gets a separate ACCESSKEY than that given to each of the
individual elements.
FIELDSET containers are nestable, but each should contain only a single CAPTION field.
Chapter 13
Inserting Objects into a Web Page
Three Ways to Go
There are three ways to put multimedia objects into your pages: browser plug-ins, ActiveX controls,
and Java applets. You'll briefly examine each in this chapter.
You'll also learn how to use HTML tags to insert any of these three kinds of multimedia "players" into
your HTML documents. Let's start by looking at browser plug-ins.
When a user starts a Web browser--Netscape Communicator, for example--on her desktop, it checks
the appropriate folder (see Table 14.1) to see what plug-ins are installed. Communicator makes a note
of each plug-in and its MIME type, which indicates the type of file with which the plug-in is
associated.
When the user opens a Web page that embeds a multimedia file, Communicator notes the MIME type
of the file, finds a plug-in that can open that type of file (if available), and loads the plug-in, passing it
the file. The drawing in Figure 14.1 illustrates this concept for you. The most important concept for
you to understand is that you, as the HTML author, embed a multimedia file into your Web page,
while a plug-in on the user's computer actually displays that file in the Web browser.
TIP: The information contained in this section is valid for all plug-ins, whether you use the <EMBED>o
tag or <OBJECT> tag to insert them.
Embedded Plug-ins
Embedded plug-ins are visible on the Web page and display inline with the rest of the Web page's
content. Embedded plug-ins always occupy a rectangular area on the Web page (see Figure 14.2). You,
as the HTML author, embed the multimedia file in the Web page, and the plug-in, on the user's
computer, displays that file inside the Web page.
Full-Page Plug-ins
Other plug-ins are full page; they don't occupy space in the Web page itself, but occupy the entire
browser window. After the user has finished interacting with the plug-in, she can click Back on
Communicator's Navigation toolbar to return to the original Web page.
With the latest Web browsers, and thanks to the efforts of the World Wide Web Consortium (W3C),
you have two different ways to embed plug-ins into your Web page. You can use the old sturdy
<EMBED> tag, or you can use the new HTML 4.0 standard <OBJECT> tag. Making this choice is a lot
harder than actually writing the HTML for either. Here are some thoughts on the subject, though, that
might help you:
• Use the <EMBED> tag if you're concerned with compatibility across a variety of Web browsers.
This Netscape extension has been in place since Navigator 2.0 and thus many other Web
browsers have adopted its use.
• Use the <OBJECT> tag if (1) you want to be hip to the latest HTML technology, (2) you want to
conform to the HTML 4.0 standard, or (3) you want to use the <OBJECT> tag's apology section
to supply content for those browser's that don't support plug-ins. The simple truth of the matter
is that both Microsoft and Netscape are adopting the use of the <OBJECT> tag for this kind of
work, so you might want to start doing it yourself.
<EMBED>
You have a fair amount of control over any plug-in that you embed into your Web page using the
<EMBED> tag. You can control its size, for example, or whether or not the browser actually displays the
plug-in. Many plug-ins also allow you to set additional attributes that control them. Table 14.2
describes each attribute of this tag.
Many plug-ins also have private attributes. Communicator looks for all of the attributes described in
Table 14.2 when it parses the <EMBED> tag, but it ignores other attributes. When Communicator loads
the associated plug-in, it passes the plug-in all of the attributes it found. For example, many audio
plug-ins have a private attribute called AUTOSTART, which indicates whether or not you want the plug-
in to immediately start playing the sound file when it loads.
<OBJECT>
W3C has made the <OBJECT> tag an official part of HTML 4.0. Many vendors, however, including
Microsoft and Netscape, had already adopted the <OBJECT> tag before the specification was finished.
You can get the full details on this tag at W3C's Web site: http://www.w3.org/pub/WWW/TR/WD-
object.
Using the <OBJECT> tag is just a bit more complicated than using the <EMBED> tag. You have to form
the <OBJECT> tag as described in Table 14.3, specify any required parameters using the <PARAM> tag,
and provide content for those users who have browsers with no <OBJECT> support or who don't have
the required plug-in. This topic is covered in depth later in this chapter, in the ActiveX section.
Sandwiching <PARAM> Tags You can provide additional properties to the plug-in, if the plug-in
supports them, using the <PARAM> tag. You embed a <PARAM> tag between the beginning and ending
<OBJECT> tags for each property you want to provide to the plug-in, like this:
<OBJECT definition>
<PARAM NAME="LOOP" VALUE="TRUE">
</OBJECT>
Using the <PARAM> tag is similar to using private properties with the <EMBED> tag. The NAME attribute is
the name of the property and the VALUE attribute is the actual value that you want to assign to that
name. Thus, the following PARAM tag is equivalent to the AUTOSTART attribute in the <EMBED> tag you
see just below it: <PARAM NAME=AUTOSTART VALUE=TRUE>
• If the browser can handle the <OBJECT> tag and it has a plug-in available for the specified data
type, the browser parses the <OBJECT> tag and any <PARAM> tags contained within it. It ignores
everything else, though.
• If the browser can handle the <OBJECT> tag, but it doesn't have a plug-in available for the
specified data type, the browser ignores the <OBJECT> tag and the <PARAM> tags contained
within it. The browser does parse any other content contained within the <OBJECT> tag,
however.
• If the browser can't handle the <OBJECT> tag, it won't be able to handle the <PARAM> tag either.
By design, the browser will not parse those tags, but will parse anything else in its path,
including content inside the <OBJECT> tag.
Consider Listing 14.1, for example, which is an example of inserting a multimedia file into a Web
page. If the browser doesn't do the <OBJECT> tag, all it's going to parse is the <A>, <IMG>, and </A>
tags. If the browser does support the <OBJECT> tag, but it doesn't have a plug-in for MOX files, it
ignores the <OBJECT> and <PARAM> tags, parsing the same tags as in the previous case. Last, if the
browser does support the <OBJECT> tag and it has a plug-in for MOX files, it parses the <OBJECT> and
<PARAM> tags, ignoring everything else.
The copyright laws apply to electronic expression as much as they do to other forms. Thus, the Web
pages and multimedia files you find on the Internet can have copyrights with just as much weight as
the copyright on this book. Ignorance isn't an excuse, either. Just because you didn't know that a file
was copyrighted doesn't protect you when the copyright hits the fan.
So, having scared you a bit, how do you know if an image is indeed copyrighted? It's not quite as cut-
and-dry as looking for a copyright symbol (audio clips don't have one). In fact, there is no requirement
that work contain a copyright symbol in order to be protected by the copyright laws. You can check a
few other places for a file's copyright status, however:
• Look for a copyright notice in the document that originally contained the file. This is
the most likely place to find such a notice.
• If you're using a video from a library, check the library's license agreement to see what
kind of rights you have for redistribution.
• Look for any comments embedded within the file that might include a copyright notice.
Most audio and video editors allow you to edit and view embedded comments.
Before you can jazz up your Web page with multimedia, you have to make or find it. Making your
own multimedia content isn't always practical, especially for a novice. You have to work within a
third-party authoring environment such as a video editor and sometimes have to purchase additional
hardware such as a video camera. You can learn more about creating your own multimedia content in
Part IV, "Serving Multimedia Content."
Using free or store-bought multimedia libraries is the quickest route to multimedia bliss. Most
multimedia libraries come with a combination of graphical images, sound clips, and video clips. Some
libraries do include a handful of Shockwave files, too. While you can find a whole host of different
plug-ins, you'll mostly use audio and video in your Web page. It's a reality for most HTML authors,
and that's good for two reasons:
• Netscape Communicator, and most other Web browsers, have the built-in capability to play
audio and display video files. Netscape has LiveAudio and LiveVideo, for example. Microsoft
has ActiveMovie.
NOTE: To see a list of those types of plug-ins that come with Communicator, choose Help, About
Plug-ins from Communicator's main menu. You'll see a list similar to that shown in Figure 14.3.
Audio
Netscape Communicator comes with an audio plug-in called LiveAudio. As shown in Figure 14.4,
LiveAudio has a very simple user interface that the user can interact with to stop, play, and pause the
audio clip, as well as adjust the volume. LiveAudio handles a majority of the sound files you'll find on
the Internet. It definitely handles WAV and MIDI files, which takes care of most of the audio content
you'll embed into your Web page.
NOTE: A user must have a sound card and speakers installed in her computer in order to hear any
audio clips embedded in your Web page. Chances are good that most users do have a sound card these
days, though.
You can use either the <EMBED> or the <OBJECT> tag to embed an audio file into your Web page.
Listing 14.2 shows you an example of a Web page that uses <EMBED>. The SRC, WIDTH, and HEIGHT
attributes are the same ones you learned about earlier in this chapter. If you want the user to see the
audio controls, you must use the WIDTH and HEIGHT attributes. The best size for the controls is 144
pixels wide and 60 pixels high.
Listing 14.3 shows you the same example using the <OBJECT> tag. The parameters are the same as
those for the <EMBED> tag, except that you use the DATA attribute instead of the SRC attribute to specify
the source file.
TIP: Choose MIDI files over WAV files every chance you get. For the same file size, you can get a
much longer audio clip from a MIDI file than you can from a WAV file. It's more economical.
Video
Like audio, you can use the <EMBED> or <OBJECT> tag to embed a video into your Web page. Listing
14.4 shows you an example of a Web page that uses the <EMBED> tag to embed an AVI file into a Web
page. The SRC, WIDTH, and HEIGHT attributes are the same ones you learned about earlier in this
chapter.
Listing 14.5 shows you the same example using the <OBJECT> tag. Note that the parameters are the
same as those for the <EMBED> tag, except that you use the DATA attribute instead of the SRC attribute to
specify the source file. In this example, you see the <IMG> tag sandwiched in the object, which
provides alternative content for users who can't display videos. Figure 14.5 shows what this video
looks like in Communicator.
AVI Files (LiveVideo) LiveVideo, which is the plug-in for AVI files, has some additional private
attributes that you can use to better control how the plug-in displays in the browser. You see those
attributes in Table 14.5.
TIP: Turn your favorite AVI video into an animated GIF. Download the GIF Construction Set from
Ziff-Davis (http://www.hotfiles.com), which converts an AVI file into an animated GIF frame by
frame. It cuts the size of the file in half, and allows the user to see the animation as the file loads from
the Web server.
MOV Files (QuickTime) The QuickTime plug-in included with Netscape Communicator also has
some private attributes that you can specify to control how it displays in the browser. You see those
attributes in Table 14.6.
The solution? Provide a link on your Web page to the video clip. If a user wants to see the video clip,
she can click on the link--it's her choice. For example, you might add a link to your Web page, with a
warning, that looks something like this: Take a look at this AVI video of my new Yorkie.
This video is 1M in size. At 14.4K, it'll take over nine minutes to download. At
28.8K it'll take over four minutes.
You'll need to use a third-party plug-in if you want to embed multimedia content into your Web page
other than video, audio, and VRML--for example, Shockwave.
TIP: If you use a plug-in that the user isn't likely to already have installed, use the PLUGINSPAGE
attribute to point Communicator to the download page for that plug-in. Doing so will help
Communicator install the plug-in more or less automatically.
ActiveX controls are small applications that run only on Windows platforms and only in Microsoft
Internet Explorer (IE).
That's a bit of an oversimplification, actually. There is a plug-in that lets ActiveX controls run in
Netscape Navigator, if you really want to use them. However, it's best to assume if you use ActiveX
controls that your target audience will be using IE on a Windows platform.
That having been said, it should be noted that there is one very good reason for using ActiveX controls
in your HTML documents: if you know they're going to be viewed on a Windows system in Internet
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
169
Shree M .& N. Virani Science College
Explorer, ActiveX controls are the fastest, most efficient objects you can use for multimedia and
interactive controls. Why? Because ActiveX controls are written to run natively on those machines.
Where plug-ins are often big and unwieldy, and Java applets must be interpreted before they are run,
ActiveX controls download automatically, reside on your system, and run efficiently under Windows.
You use the <OBJECT> tag to insert ActiveX objects into an HTML document. With regard to ActiveX
controls, the <OBJECT> tag identifies the control you're using. That is, the <OBJECT> tag identifies
which control on the user's computer you want to use and gives that instance of the control a name,
which you can use in scripts. That's all.
In the following sections, you'll learn much more about each of the <OBJECT> tag's attributes as they
relate to ActiveX controls. Before doing that, however, take a look at how you use the <OBJECT> tag in
a Web page. In its simplest form, the <OBJECT> tag looks something like this:
<OBJECT
classid="clsid:1A771020-A28E-11CF-8510-00AA003B6C7E"
id=Track1
width=400
height=2
align=left>
<IMG SRC="noobject.gif">
<PARAM NAME="Image" VALUE="image.gif">
</OBJECT>
The CLASSID attribute uniquely identifies, on the computer, the control you're using. Every control
installed on the user's computer is installed in the Registry. The control's CLASSID is the number that
Windows uses to identify that control. You can think of the CLASSID as a name that is guaranteed to be
unique. You'll learn more about this attribute later. In this case, we're using the View Tracker control.
You use the ID attribute to identify the control to the scripts in your Web page. WIDTH, HEIGHT, and
ALIGN work the same as with other types of tags; they specify the size and location of the control on
the Web page.
You will need to set the properties of the ActiveX controls you put on the Web page in order to control
its appearance or function. For example, you need to give the Stock Ticker control the URL of the text
file it should use for data. You need to provide the Label control with the text it should display. The
only way to know for sure which properties each control requires is to check the control's
documentation. You can also use the ActiveX Control Pad to set a control's properties.
So, how do you set these properties? You use the <PARAM> tag to assign a value to a named property
within the control. This works very much like Visual Basic property sheets. Note the <PARAM> tag has
no closing </PARAM> tag. Table 21.2 describes the attributes you use with the <PARAM> tag. You
frequently need to use only the NAME and VALUE attributes.
NAME, VALUE, and TYPE are self-explanatory. Table 21.3 describes the settings you can use with
VALUETYPE.
The following is an example of inserting an ActiveX control by using the <OBJECT>tag. The CLASSID
attribute specifies the Popup Menu control, and each <PARAM> tag adds a menu item to the menu.
<OBJECT
id=iemenu1
classid="clsid:0482B100-739C-11CF-A3A9-00A0C9034920"
width=1
height=1
align=left
hspace=0
vspace=0
>
<PARAM NAME="Menuitem[0]" VALUE="First Choice">
<PARAM NAME="Menuitem[1]" VALUE="Second Choice">
<PARAM NAME="Menuitem[2]" VALUE="Third Choice">
<PARAM NAME="Menuitem[3]" VALUE="Fourth Choice">
<PARAM NAME="Menuitem[4]" VALUE="Firth Choice">
</OBJECT>
The <OBJECT> tag has a number of attributes you can use. The sections that follow describe each
attribute. In reality, however, you'll find yourself using only a few: CLASSID, ID, HEIGHT, WIDTH,
ALIGN, and, possibly, CODEBASE.
ALIGN You use the ALIGN attribute to specify where to place the object. You can position an object
relative to the text line or on its own on the left, right, or center of the page. Table 20.4 describes the
settings you can use to align the object with the text line. Table 21.5 also describes the settings you can
use to align the object with the page.
TEXTTOP The top of the object is aligned with the top of the current font.
MIDDLE The middle of the object is aligned with the baseline of the text line.
TEXTMIDDLE The middle of the object is aligned with the middle of the text line.
BASELINE The bottom of the object is aligned with the baseline of the text line.
TEXTBOTTOM The bottom of the object is aligned with the bottom of the current font.
BORDER When you use an object as part of a hypertext link, you can specify whether or not the
object has a border. The BORDER attribute specifies the width of the border around the object. If you
don't want a border around the object, set this attribute to 0, like this: BORDER=0.
CLASSID and CODEBASE You use CLASSID to refer to the ActiveX control to be placed within the
object's borders. There are several different ways to indicate the object to be inserted here. ActiveX
uses the clsid: URL scheme to specify the ActiveX class identifier.
ON THE WEB: For further information on the clsid: URL scheme, see
http://www.w3.org/pub/WWW/Addressing/clsid-scheme.
The best way to obtain the CLSID for an ActiveX control is to look at the control's documentation. You
can look up Microsoft's ActiveX controls at Microsoft's ActiveX Gallery. Alternatively, use the
ActiveX Control Pad to insert an ActiveX control in your Web page so you don't have to worry about
the CLSID. If the CLASSID attribute is missing, ActiveX data streams will include a class identifier that
can be used by the ActiveX loader to find the appropriate control.
The CODEBASE attribute can be used to provide an URL from which the control can be obtained. If the
control is already installed on the user's computer, the browser will do nothing with this attribute. If the
control isn't installed on the user's computer, however, the browser will try to download the control
from the URL in CODEBASE and install it.
NOTE: You can also get the CLASSID for an ActiveX control from the Windows Registry, like this:
1. Open the Registry Editor. Choose Run from the Start menu, type regedit, and press Enter.
2. Locate a control under HKEY_CLASSES_ROOT, such as Internet.Gradient or Internet.Label.
CODETYPE The CODETYPE attribute is used to specify the Internet Media Type for the code pointed
to by the CLASSID attribute. Browsers use this value to check the type of code before downloading it
from the server. Thus, the browser can avoid a lengthy download for those objects that it doesn't
support. Currently, the CODETYPE attribute is supported in a limited fashion in Internet Explorer 3.0.
Microsoft has indicated that TYPE will be implemented for all relevant MIME types.
DATA The DATA attribute contains an URL that points to data required by the object, for instance, a
GIF file for an image. Internet Explorer currently supports the DATA attribute.
DECLARE You'll use the DECLARE attribute to tell the browser whether to instantiate the object or not.
If the DECLARE attribute is present, it indicates the object should not be instantiated until something
references it. That is, the browser will note the declaration of the object, but won't actually load it until
you reference it.
HEIGHT The HEIGHT attribute defines the height, in pixels, to make available to the ActiveX control
when rendered by the browser. The Web browser may (or may not) use this value to scale an object to
the requested height.
HSPACE The HSPACE attribute defines the amount of space, in pixels, to keep as white space on the
left and right as a buffer between the ActiveX control and surrounding page elements. The Web
browser may (or may not) use this value to allocate white space.
ID The ID attribute defines a document-wide identifier. This can be used for naming positions within
documents. You also use the control's ID to reference it in scripts.
NAME You use the NAME attribute to indicate whether an object wrapped in a <FORM> tag will be
submitted as part of the form. If you specify NAME, the Web browser submits the VALUE property of the
object to the host. If you don't specify NAME, the ActiveX control is assumed to be decorative and not
functional in the form.
STANDBY STANDY is a short string of text the browser displays while it loads the ActiveX control.
TYPE The TYPE attribute is used to specify the Internet Media Type for the data specified by the DATA
attribute.
ON THE WEB: You can learn more about Internet Media Types by referring to RFC 1590. You can
get RFC 1590 from the Internet at ftp://ds.internic.net/rfc/rfc1590.txt.
WIDTH The WIDTH attribute defines the width, in pixels, to make available to the ActiveX control
when rendered by the browser. The Web browser may (or may not) use this value to scale an object to
the requested width.
Now, we're getting to the meat of the matter. You've learned how to insert ActiveX controls into your
Web page by using the <OBJECT> tag. Now, you need to learn how to interact with those controls by
using a scripting language. In the sections that follow, you'll learn how to handle the events that are
fired by a control. You'll also learn how to get and set a control's properties from your scripts.
Incidentally, my scripting language of choice is VBScript, so that's what I'm using in these examples.
The JavaScript versions of these examples aren't much different, however.
ActiveX controls act like and quack like the elements on a form. That is, you interact with each
ActiveX control's properties, methods, and events in exactly the same way in which you interact with a
form's element. You handle a control's events when the control needs attention; you call a control's
methods, and you get and set the control's properties.
Handling an Event
You can use a couple of different methods of handling events for forms and elements (event-
procedures, inline event handlers, and so on). One such method is to use the FOR/EVENT attributes of
the SCRIPT tag.
The FOR and EVENT attributes let you associate a script with any named object in the HTML file and
any event for that object. Take a look at the following:
You can add this code to an HTML file, and you'll see a button (with an ID of btnButton) that
executes the script when you click it. Take a look at the <SCRIPT> tag. It contains the FOR and EVENT
attributes that define the object and event associated with that script. FOR="btnButton"
EVENT="Click" says that when an object named btnButton fires the Click event, every statement in
this script is executed.
The enclosed script can then use any of the parameters passed to it by the MouseMove event.
TIP: Once you've specified a language in your HTML file, you don't need to do it again. Your browser
defaults to the most recently used language in the HTML file. You can put <SCRIPT
LANGUAGE="VBScript"> </SCRIPT> at the very beginning of your HTML file one time and forget
about it. The rest of the scripts in your file will use VBScript.
You just saw the Click event. ActiveX controls support a wide variety of other events. The best way
to know for sure which events a control supports is to consult the control's documentation or the
ActiveX Control Pad's documentation. For your convenience, however, the following list describes the
most prevalent and useful events:
• Click occurs when the user either clicks the control with the left mouse button or selects a
single value from a list of possible values.
• DblClick occurs when the user clicks twice rapidly with the left mouse button.
• MouseMove occurs when the user moves the mouse pointer over a control.
NOTE: Often, the easiest way to see the events, properties, and methods that an ActiveX control
supports is to insert it into a Web page by using the ActiveX Control Pad and pop open the Script
Many objects let the user input data. For example, the user can choose an item from a list, type text
into an edit box, or click a check box. What good are those objects if you can't get and set their value?
Not much. You read the value of most elements by using the object's value property in an assignment
or logical expression. The following example assigns the text the user typed into the txtTextBox
control to a variable called str. The next example compares the text the user typed into the
txtTextBox with the word "Howdy".
str = txtTextBox.value
If txtTextBox.value = "Howdy" Then
You can also set the value of an element from within a script by assigning a string to the element's
value, as follows:
The value property is the default property for most ActiveX controls that accept user input. Thus, you
can use them in an expression without explicitly using the value property, like this:
alert txtTextBox
txtTextBox = "New Contents of the Text Box"
Sun Microsystems's object-oriented programming language Java is creating a lot of interest on the
Web. You can use Java to create dynamic, interactive Web pages. You don't have to be a Java
programmer to use Java applets--many are available on the Web for free.
The Java language is object-oriented and very similar to C++. It was designed to take many of the best
features of C++ while simplifying it to make writing programs easier.
Programs are normally created to run on only one type of operating system. Windows 95 programs
have been specifically created to run on systems running the Windows 95 operating system and will
not run on the Macintosh or on a UNIX system. Java programs, however, are intended to be platform
independent. Java programs are compiled into a series of bytecodes that are interpreted by a Java
interpreter. After a Java program has been compiled, it can run on any system with a Java interpreter.
You do not need to recompile it.
This capability makes Java an ideal language for programs on the Web. With so many different
systems on the Web, creating programs that will work with all of them is very difficult. Because Java
programs are platform independent, programs are no longer restricted to running on one platform.
They can run on any platform to which Java has been ported.
Java programs that can be embedded into WWW pages are called Java applets. To run applets from
Web pages, you must have a browser that supports Java, such as HotJava, Netscape, or Internet
Explorer.
If you want to write your own Java applets, you should download the Java Development Kit from
Javasoft or purchase Microsoft's Visual J++. Javasoft is available for free on the Web. You can
download it from the Javasoft Home page at http://www.javasoft.com.
Microsoft Visual J++ is relatively inexpensive. You can purchase it at most computer retailers such as
CompUSA or Computer City.
Now take a look at a few examples. Listing 14.1 shows the code for a simple Java applet.
When you place this applet into a page and run it, it prints Hello World!. But, before you can use it in
a page, you must compile the applet using javac, the Java compiler. The files that Javac creates are
called Java class files. A class file is the platform-independent object file that the browser retrieves
when downloading a Java applet.
To use this applet on an HTML page, you have to describe it using the <APPLET> tag. Listing 14.2
shows an HTML page that loads this example applet.
The <APPLET> and </APPLET> tags act as a container for the Java applet definition. They indicate to
the browser that a Java applet should be loaded. The CODE attribute tells the browser which Java applet
should be downloaded. The browser reserves space in the page by using the WIDTH and HEIGHT
In this case, the applet being downloaded is HelloWorld, and it reserves a space 150 pixels high and
200 pixels wide in the page. Figure 14.7 shows what the page looks like when the browser loads it.
Browsers that can't display Java applets don't display anything when this page is loaded. To prevent
this situation from happening, you can place HTML markup or text between the <APPLET> and
</APPLET> tags. Browsers that can't display Java applets display the HTML markup instead. You can
use this approach to tell visitors to your pages what they would have seen if the applet had loaded.
Browsers that can display applets don't display any of this HTML markup. Listing 14.3 shows an
HTML page with alternative HTML markup.
TIP: You aren't restricted to writing Web applets with Java. You can write full applications with it as
well. The HotJava browser and the Java compiler are both written in Java.
The CODE, WIDTH, and HEIGHT attributes of the <APPLET> tag are all required. You also can use other
attributes in the <APPLET> tag. Table 14.1 shows the attributes available and their functions.
ALIGN Defines how this applet is aligned in the HTML page. Any of the ALIGN options discussed
in previous chapters are legal here.
VSPACE Defines how many pixels of space are reserved above and below the applet.
HSPACE Defines how many pixels of space are reserved on either side of the applet.
As of HTML 4.0, the <OBJECT> tag is actually the "preferred" method of inserting plug-ins, ActiveX
controls, and Java applets into HTML documents. However, the <EMBED> and <APPLET> tags will be
supported for backwards compatibility.
Using the <OBJECT> tag to insert a Java applet is actually quite similar to using the <APPLET> tag
method. Many of the same attributes are supported. Here's a simple example:
This example adds the CODETYPE and CODEBASE attributes, and includes an added PARAM element:
In short, using the <OBJECT> tag with Java applets isn't much different from using it with ActiveX
objects or plug-ins.
Chapter 14
Adding JavaScript and VBScript to HTML
Introducing Scripts
Scripts are important to an HTML author. I'm of the strong opinion that in the future you'll focus more
on writing scripts than HTML tags. Whereas to create a document's content you'll use an HTML
editor, which works like any popular desktop publishing program, you'll write scripts to make those
documents interactive. Think of it this way: You use a word-processor to create documents, but you
still must write the occasional macro to make a document interactive or solve special problems.
You're not going to learn how to write good scripts after reading this one chapter. Though it is a good
basic introduction to scripting, particularly to the mechanics of adding scripts to HTML, you can't rely
on it to teach you how to program. For that, take a look at Que's Special Edition Using JavaScript or
Special Edition Using VBScript. If you're already familiar with the basic programming concepts,
however, you can rely on Appendixes C, "JavaScript Keyword Reference," and D, "VBScript
Keyword Reference," to show you all of the keywords supported by both scripting languages.
Server-side (see Part VI, "Scripting on the Web Server") scripts execute on the Web server, feeding
HTML to the browser as a product of their computations. Write a server-side script for each
circumstance if any of the following statements is true:
• You're serving customized content based on information you know about the user.
• You need to include output from a legacy application or database in your HTML documents.
• You're writing a client-side script just to generate HTML as the user opens the Web page.
• You have to process a user's form input on the server (transaction or search processing, for
example).
NOTE: Writing a server-side script isn't always possible, particularly if the service hosting your Web
pages doesn't support server-side scripts. In such cases, you have no choice but to write a client-side
script or relocate your Web pages to a service that does support scripts.
Client-side scripts interact with the HTML while the user is viewing it. Write a client-side script if any
of these statements is true:
• Your script must interact with the user's environment, creating a canvas window that doesn't
have toolbars or menus, for example.
• You want to change the appearance of the Web page as the user interacts with it.
• Writing a server-side script would require frequent round-trips to the server to change the
document's content.
JavaScript is loosely based on C++ and has gained worldwide acceptance on the Internet. You can use
JavaScript to interact with the user's environment, change the appearance of the content while the user
interacts with it, and even make embedded objects cooperate with each other. Both Netscape Navigator
and Internet Explorer support JavaScript.
VBScript is based on Microsoft's Visual Basic. You also use it to create client-side scripts that interact
with the user's environment, change content dynamically, and glue together objects. VBScript's biggest
advantage is that you can leverage your existing knowledge about Visual Basic onto the Web page.
Currently, Internet Explorer is the only Web browser that supports VBScript directly--a pretty big
weakness.
When choosing between each of these languages, consider the following criteria for making your
decision:
• Do your scripts have to run on both Internet Explorer and Netscape Navigator? If so, use
JavaScript.
• If you don't yet know how to program and you want to get up-to-speed quickly, start with
VBScript because it's the easier language to learn--particularly if you already know Visual
Basic.
• Do you need the flexibility of creating complex scripts involving advanced data structures and
programming constructs? If so, your best bet is JavaScript because it's more versatile than
VBScript.
TIP: You can mix both JavaScript and VBScript within the same HTML file, so you're not forced to
make a black-or-white decision. Do remember that Internet Explorer is the only browser supporting
VBScript at this time.
JavaScript and VBScript are interpreted languages as opposed to compiled languages. Developers
create programs using a compiled language such as C++. A compiler actually translates each
instruction into machine code that the computer executes directly. A program called an interpreter
interprets and executes a script line by line, however.
An interpreted language is slower than a compiled language, but, considering the usage of an
interpreted language, that's not really an issue. Your scripts are interpreted by the Web browser and are
When a user opens a Web page, the browser makes note of every script in the HTML document. It
translates the scripts into intermediate code that represents the keywords in the script as tokens (binary
values representing the keywords), which are more efficient to interpret because they're smaller than
the original keywords. It also creates a table called a symbol table that contains the name of each script
function (scripts that are called by name from other scripts). The browser looks up functions in this
symbol table as they are invoked.
The user's Web browser executes different types of script code at different times. The browser
typically doesn't execute functions as the Web page loads; it waits for an event that you associate with
a function to execute them instead. When an object on the Web page fires an event, the browser looks
up the function associated with that event in the symbol table; then the browser executes it. Also,
anytime a script invokes a function, the browser looks it up in the symbol table to find the code. The
browser executes inline scripts as it loads the Web page, however. Inline scripts are code you embed
that's not actually inside a function. You use inline scripts to affect how the browser draws the Web
page.
In Listing 16.1, for example, the last line in the script executes as the browser loads the Web page,
which creates the Web page shown in Figure 16.1. The remaining lines don't execute until some event
causes the function called AddSeries to execute.
With scripting, you embed instructions into your Web pages that describe how you want the browser to
handle certain events. Events are things that happen on the Web page. Mouse actions such as clicking
and moving cause most events, but many other types of events can occur on a Web page such as a
timer finishing its countdown. Regardless, most events are caused by some action.
Figure 16.2 illustrates this event-driven concept. Figure 16.2 has three key parts: an object, the event
itself, and the event handler. The following list describes the three parts:
• An object can be anything on the Web page--a button will do nicely, but any HTML tag can
also generate events.
• Event handlers take action on the event. To create an event handler, you associate a function
with the event. Then the browser executes that function whenever that event occurs.
Events have many benefits over the old style of programming. The biggest benefit is the fact that you
stay in control of the computer. Here are the highlights:
• You determine the order in which a program executes. Clicking different parts of the
screen, such as buttons, menus, and windows, causes different bits of code to execute.
Contrast that to a procedural application that determines the order in which the code
executes: starts at the beginning, expects to see certain inputs at certain times, and stops
when it hits the last line of code.
• When an event-driven program is waiting for an event, it's not using much of the
computer's resources. This lets the computer do other tasks, such as run other programs.
Event-driven programs have a message loop that checks for messages. If no messages
are waiting, the program returns control back to the operating system to give another
program a shot.
You can write scripts in two ways. The first way is by using a wizard such as the Scripting Wizard that
comes with Microsoft FrontPage and FrontPage Express. These wizards allow you to write very simple
scripts and associate them with events and objects using a intuitive mouse-driven interface. If you're
interested in approaching scripts this way, you don't need to learn how to program. You can learn more
about using Microsoft's Scripting Wizard in "Writing Scripts with the ActiveX Control Pad," later in
this chapter.
You can also write scripts the old-fashioned way: using a text editor. Doing so requires that you have
an intimate understanding of the script language you're using. You can type your scripts directly into a
file using your HTML editor, or you can type them into a plain text file that you link to your HTML
Variables
Variables are names for a small chunk of memory in which you store a value. Variables can store a
number or any bit of text. You don't need to worry about where in the computer's memory the script
stores the variable's value because you use the variable's name to change or read its value.
Mathematical Expressions
Mathematical expressions return the result of a calculation. Two things make up a mathematical
expression: operands (numbers, strings, or variables) and operators. When you add two numbers using
a calculator, the numbers are the operands, and the plus sign (+) is the operator. Likewise, the minus (-
), multiplication (*), and division signs (/) are operators. In most cases, you assign the result of a
mathematical expression to a variable so that you can recall the result later. Examples of mathematical
expressions written in JavaScript include the following:
NOTE: An operator's level of precedence determines the order in which the interpreter evaluates each
operator in an expression. A multiplication operator has a higher order of precedence than an addition
operator, so the interpreter evaluates the multiplication operator first.
The exception to this rule is when you put a portion of the expression inside parentheses. The
interpreter evaluates anything you place inside parentheses before it evaluates the rest of the
expression. If you have one set of parentheses with another, the interpreter evaluates the innermost set
before evaluating the outermost set.
Boolean Expressions
Boolean expressions let you make decisions. They always evaluate to one of two values: True or
False. You can assign the result of a Boolean expression to a variable, use it to control a loop, or use it
to make a decision.
Logical operators let you combine multiple comparison operators in a single expression. They're very
simple to use; you plug in a couple of values and get a predictable result in return. For example, A And
B is always True if both values are True. It's always False if either value is False. The following list
describes the most important logical operators that JavaScript and VBScript support:
Not The Not operator negates a Boolean value. Not True returns False, for example, and Not False
returns True.
And The And operator compares two Boolean values and returns True if both values are True.
Otherwise, it returns False. Table 16.2 shows you the result for each combination of Boolean1
and Boolean2.
Or The Or operator compares two Boolean values and returns True if either value is True. Otherwise,
it returns False. Table 16.3 shows you the result for each combination of Boolean1 and Boolean2.
Xor The Xor operator compares two Boolean values and returns True if both values are different.
Otherwise, it returns False. Table 16.4 shows you the result for each combination of Boolean1 and
Boolean2.
The following are some examples of Boolean expressions that rely on logical operators:
2 < 3 And 4 > 5 Returns False because this expression evaluates to True And False.
1 > 0 And 4 < 5 Returns True because this expression evaluates to True And True.
2 < 3 Or 4 > 5 Returns True because this expression evaluates to True Or False.
x < 0 And y > 0 Returns True if x is negative and y is positive.
x Or y Returns True if either variable contains a True value.
Decisions
VBScript and JavaScript contain a variety of statements you can use to control how your script flows.
The syntax is different in each language, but both languages have roughly the same form.
The most basic type of decision making statement you'll use is the If...Then...Else statement. This
statement evaluates a decision and conditionally executes a block of statements depending on the
result. The statement has many different forms, but in general it looks like this:
If Condition Then
The first line is the heart of the If...Then...Else statement. It begins with the keyword If and ends
with the keyword Then. Condition, the middle part, is the criteria. This is a Boolean expression that
evaluates to either True or False. You learned to write Boolean expressions earlier in this chapter. If
the condition is True, the script executes the first block of statements; otherwise, the script executes
the second block of statements.
The following example shows you an If...Then..Else statement written in JavaScript. The
condition is x < 3. If that condition is True, the interpreter executes the first alert statement. If that
condition is False, the interpreter executes the second alert statement.
if( x < 3 )
alert( "x was less than 3" );
else
alert( "x was equal to 3 or greater" );
Loops
You can write a script that repeatedly executes the same statements until some condition is met or,
alternatively, until some condition is not met. This is called looping. The primary reason to write a
loop is so that you don't have to repeat a bunch of statements, like this:
You can put these statements in a loop, instead, and let the script repeat them for you:
Both VBScript and JavaScript support a variety of looping mechanisms, each with its own syntax. In
general, though, a loop looks like this:
Loop Condition
Statements
Statements is called the body of the loop. The interpreter iterates the loop over and over until
Condition becomes True. Each time the interpreter does so, it executes the statements in the body of
the loop.
The following example shows you a while loop in JavaScript. As long as i is less than 10, the
interpreter executes the two statements contained in the body of the loop. The first statement simply
displays the current value of i. The second statement adds 1 to i. The number of times that this loop
while( i < 10 )
{
alert( i );
i = i + 1;
}
Functions
Functions (and subprocedures in VBScript) let you divide your scripts into chunks you call from any
other script. Invoking a function in your script is called calling a function. You give a function a name
and a list of arguments. You call the function by its name and pass arguments by their position. In
general, a function looks like this:
Name( Arguments )
Statements
End
Name is the name of the function, which you use to invoke the function from a script or associate the
function with an object's event. Arguments is a list of parameters that you pass to the function as
variables. Statements is all the code you want the interpreter to execute each time it invokes the
function. A function can also return a value to the calling script; thus, you can use a function on the
right side of an equal sign, like this:
1. You call a function by name to invoke it, passing any values on which you want it to operate
as arguments.
2. The interpreter executes the function, setting each variable in the argument list to the values
you passed.
3. When the function finishes, it specifies a return value to the interpreter, which returns the
result in the expression that invoked the function.
You embed scripts in an HTML file using tags, much like any other content you put in a Web page.
Scripts are put between the <SCRIPT> and </SCRIPT> container tags, as shown in Listing 16.2. You
specify the language you're using by assigning the MIME type of the language to the TYPE attribute:
text/vbscript for VBScript or text/javascript for JavaScript.
When your browser loads a Web page that includes scripts (parse time), it immediately evaluates each
<SCRIPT> block it encounters. The browser grabs everything in a <SCRIPT> block and passes the
content off to the scripting engine. The scripting engine looks at the <SCRIPT> block the browser gave
it and looks for any functions and global variables (variables outside a function). The scripting engine
compiles the functions and global variables and stashes their names in the symbol table for later use.
The scripting engine immediately executes statements it finds outside a function, though. This is called
immediate execution. Scripts that the browser executes immediately are called inline scripts.
NOTE: Prior to HTML 4.0, you might have used the LANGUAGE attribute to specify the scripting
language you're using. W3C encourages you to use TYPE instead of the LANGUAGE attribute because its
values are not standardized. Note that Internet Explorer and Navigator don't support the TYPE attribute
as of this writing. Until both browsers do, you can safely use the LANGUAGE attribute to specify the
scripting language by assigning either JAVASCRIPT or VBSCRIPT to it, like this:
<SCRIPT LANGUAGE=JAVASCRIPT>
<SCRIPT LANGUAGE=VBSCRIPT>
You can specify a default scripting language for an HTML file and forget about specifying it within
each <SCRIPT> tag. You use the <META> tag at the beginning of your HTML file. Set HTTP-EQUIV to
Content-Script-Type and set CONTENT to the MIME type of the scripting language you're using. The
following example sets the default language for the HTML document to JavaScript:
You can also set the default scripting language using an HTTP header as shown in this example for
VBScript:
Content-Script-Type: text/vbscript
CAUTION: Failing to specify the scripting language you're using is not only incorrect but also can
cause problems for you in the future. Either define your choice globally or within each <SCRIPT> tag,
but don't rely on the browser's default scripting language to always be JavaScript or VBScript.
Because you must still specify the language using the TYPE attribute, you can use only a single
language within each text file. To help identify the types of scripts stored in each file, use an
appropriate file extension. Consider using the following conventions:
• Use the VBS file extension for files containing VBScript scripts.
Many browsers can't interpret scripts. When one such browser encounters a script, it ignores the
<SCRIPT> and </SCRIPT> tags because it doesn't know how to interpret them (this behavior is by
design). Then the browser displays everything between those two tags as content, which is not exactly
what you had in mind. Figure 16.3 shows an example of what this looks like.
You use an HTML comment to hide scripts from browsers that don't support scripting, however. Make
the opening HTML comment the first line within the script. The closing HTML comment should be
the last line in the script block. Note that when using JavaScript you begin this line with a JavaScript
comment (//) because after JavaScript starts interpreting code, it thinks that everything else in the
script is actual JavaScript code. VBScript users begin the same line with a VBScript comment (`).
Script-enabled browsers ignore the comments and interpret the scripts, whereas other browsers ignore
all the content between the comments. Listing 16.3 shows you a JavaScript example.
Most objects on a Web page have events. That includes each HTML tag, control, or form element.
Some events to which you attach scripts include those listed in Table 16.5.
Recall from Figure 16.2 that objects, events, and event handlers all work together. You have to
associate an object with an event handler via that object's event. You do that by adding the event's
attribute to the object's HTML tag and setting its value to a single statement that executes the function.
For example, to associate a JavaScript function called MyFunction() with the onClick event of a
button, you write the button's <INPUT> tag as follows:
You can just as easily associate an event handler with any other event in Table 16.5. In this case, the
event attribute is onClick. Add another event attribute from the first column of Table 16.5 to the tag in
the preceding example to associate an event handler with that event, like this:
You can also use the FOR and EVENT attributes, which let you associate a script with any named object
in the HTML file and any event for that object. Take a look at the following:
This defines a button (with a NAME of Button) that executes the script when the user clicks it. The
<SCRIPT> tag contains the FOR and EVENT attributes that define the object and event associated with
that script. FOR="Button" EVENT="Click" says that when an object named Button triggers the Click
event, every statement in this script is executed.
There is certainly a better way to add scripts to your HTML documents. The ActiveX Control Pad is a
free product from Microsoft that makes short work of this. You get it through Microsoft's Site Builder
Workshop at http://www.microsoft.com/workshop/author/cpad. Figure 16.4 shows you the Control
Pad's HTML editor with an HTML file in it.
TIP: The Control Pad uses VBScript by default. If you want to use JavaScript, you need to set it to do
so. Choose Tools, Options, Script from the main menu and select JavaScript. The Script Wizard now
generates JavaScript language scripts rather than VBScript.
The Script Wizard provides two different ways you can edit scripts: List view and Code view. List
view is a bit easier to use. Click the Script Wizard button in the toolbar to open the Script Wizard.
Then click the List View button at the bottom of the window. See the window shown in Figure 16.5.
You associate an object's event with another object's methods and properties. Select an event on the
left pane of the wizard. Choose a method or property in the right pane. When you click the Insert
Action button, the Script Wizard prompts you for the value of the property or for any parameters you
want to pass to a method. You can rearrange the order of the actions in the bottom pane of the Script
Wizard. Close the Script Wizard, and it'll add your script to the HTML file.
If you're more comfortable with the traditional programmer view of life, use the Script Wizard's Code
view (see Figure 16.6). This works just like the List view, except that you don't see a list of associated
events and actions in the bottom pane. You see the actual code the Script Wizard creates instead. Click
the Script Wizard button in the toolbar to open the Script Wizard. Then click the Code View button at
the bottom of the window, add your script, and close the Script Wizard.
TIP: Keep your Web browser running with the Web page on which you're working in it. Then you can
save the changes, flip to the browser, and refresh the Web page to see your changes while you're
working in Control Pad.
The quickest way to add scripts to your Web page is by using a script that you download from a gallery
or library. For example, the Template Studio (http://tstudio.usa.net) is a comprehensive gallery that
contains numerous scripts you can use in your Web page. The scripts you find on this site include
scripts for detecting the user's browser, dynamically replacing an image, controlling a window,
displaying messages, and setting cookies.
If you want even more immediate gratification, however, you can try out the scripts described in the
following sections. These scripts help you add fly-over help for the links on your Web page.
TIP: Netscape provides more than a dozen, real-world example JavaScript Web pages that you can
use. Open http://developer.netscape.com/library/examples/examples.html#javascript in your Web
page.
Take a look at Communicator's status line when you hold the mouse pointer over a link. It shows the
URL to which the link points. You can provide a more useful description of the link's destination by
using a script (see Figure 16.7).
You use the <A> tag's onMouseOver event to display the help text and its onMouseOut event to remove
the text. For every link on your Web page, add the following onMouseOver attribute to its <A> tag.
Each time the user moves the mouse over the link's anchor, the two statements assigned to this event
execute. The first statement, self-status='The help text'; displays the text contained within the
single quotes on the browser's status line. Change this text to a brief description of the link. The
following shows the second statement, return true;, which prevents the browser from displaying the
link's URL reference on the status line:
Also add the onMouseOut event attribute to each <A> tag as you see in the following example. This
works just like the onMouseOver attribute you just read about except that it clears the status line when
the user moves the mouse out of the link. The effect is that the user sees the help text as long as she
holds the mouse over the link; but when she moves the mouse away from the link, the status line
clears.
If you've visited Microsoft's site recently, you've seen forms used for navigation. Here's how it works:
you select an item from the drop-down list and click a button. The browser opens the URL associated
with that list item (see Figure 16.8).
Listing 16.4 shows the HTML for a form with a single drop-down list. It opens the Web page that the
user chooses from the list. The function OpenURL() is associated with the <SELECT> tag's OnChange
To make this work in your Web page, you need to update the form's list to contain an entry for each
Web site to which you want the user to navigate. Then you need to add a line to the OpenURL function
that checks the index of the user's selection and opens the appropriate URL in the browser. The easiest
thing to do is to copy one of the existing lines, change the index number so that it corresponds with the
form, and then change the URL assigned to window.location. Just remember that the first item in the
list has an index of 0, the second has an index of 1, and so on.
Chapter 15
Applying Cascading Style Sheets
A critical portion of W3C's HTML 4.0 recommendation is style sheets, particularly if you're interested
in dynamic HTML. Style sheets let you separate the content of your HTML documents from their
presentation. And by associating scripts with HTML elements, you can change the document's format
as the user interacts with the it.
The two major Web browsers, Internet Explorer 4.0 and Netscape Communicator, support style sheets
defined by HTML 4.0: Cascading Style Sheets Level 1 (CSS1). They both support CSS1 to varying
degrees, though.
W3C treats the style sheet mechanism (the HTML used to associate styles with a document) separately
from the style sheet language (the statements that specify formatting). CSS1 is the most prevalent style
sheet language, however, so I'll show you how to write CSS1 rules in this chapter in addition to how to
associate style sheets with an HTML document. Appendix B, "Style Sheet Property Reference," covers
CSS1 in more depth.
HTML 4.0 provides the mechanism to associate a style sheet with a document, but it doesn't care what
style sheet language you're using--CSS1 or even a more complex language that's yet to be invented.
Regardless, you must specify the style sheet language to the browser so that it knows how to parse it.
You do so by using the <META> tag:
You can also define the style sheet language using the following HTTP header:
Content-Style-Type: text/css
If you don't specify a style sheet language using the <META> tag or an HTTP header, the default is
CSS1. Even though the default is CSS1, make a point of explicitly defining the language you're using
so that you don't rely on this default behavior.
You can create a style sheet in a separate file and then apply that style sheet to all the pages on your
Web site. I recommend this method because it makes creating a consistent Web site much easier. In
fact, you can create a corporate style sheet and have all members of your organization use it with their
Web sites.
To link to a style sheet stored in a separate file, store all your styles in the CSS file and link your
HTML files to it using the <LINK> tag, like this:
Assign the URL of the style sheet to the HREF attribute. Set TYPE to the MIME type of the style sheet
language, "text/css" for CSS1.
TIP: Store your corporate style sheets in a common location on the Web server and then have
everyone who is creating Web pages reference that style sheet from his or her HTML files. Everyone
can even use the same <LINK> tag. In this way, you can have a more consistent look across all the Web
pages on the server.
You don't have to store your style sheet in a separate file. You can embed the style sheet inside each
HTML file. Note that the styles within an embedded style sheet only affect the HTML within that file;
thus, you can't embed a style sheet in an HTML file and expect to use that across multiple HTML files
without copying it into each file.
You use the <STYLE> container to embed a style sheet in your HTML file. Put this container between
the <HTML> and <BODY> tags of your file, like this:
<HTML>
<HEAD>
</HEAD>
<STYLE TYPE="text/css">
Style definitions go here
</STYLE>
<BODY>
</BODY>
</HTML>
The <STYLE> tag's most important attribute, called TYPE, specifies the MIME type. It identifies the
style sheet language so that browsers that don't support style sheets or the specified language won't
display the contents of the <STYLE> container. For CSS1, set it to "text/css". The <STYLE> tag has
three other attributes that you learn about later in this chapter: MEDIA, LANG, and DIR.
Inline styles are simple styles that you define on-the-fly. You can use inline styles to quickly change
the appearance of a single tag, for example. You can also use inline styles to override a style for a
With inline styles, you define a tag's style within the tag itself. You do this by using the STYLE
attribute, which is supported by all the child tags of the BODY tag. To define an inline style, add the
STYLE attribute to the tag for which you want to change the style and set its value to the string
representing the style definition, like this:
NOTE: If an inline style conflicts with an embedded or linked style, the inline style wins. If in a linked
style sheet you define the color of an <H1> tag to be blue and you also define the color of a particular
<H1> tag within your HTML file to be red, the browser will display that particular occurrence of the
<H1> tag using the color red.
You can use inline styles with the <DIV> tag to set the style for an entire block of HTML within your
document. This works because of the concept of inheritance, which you learn about later in this
chapter. For example, if you want to change the text color of an entire block of tags to blue, you can
put those tags in the <DIV> container and define a style for the <DIV> tag that sets the text color to
blue. It looks like this:
You can also use inline style sheets with the <SPAN> tag to change the formatting for a few words or
even just a few letters. For example:
CAUTION: Don't abuse inline styles. They'll quickly clutter your HTML file so that it's more difficult
to read and much more difficult to maintain. This obviously diminishes the greatest advantage of style
sheets: separating format from content.
You learned about linking to a style sheet earlier in this chapter. You can also use the @import
keyword to import a style sheet into your HTML file; however, many browsers don't support @import
yet. Remember that you're just importing the text file, thus you have to insert it in the <STYLE>
container. In this manner, importing a style sheet works just like embedding a style sheet into your
HTML file. For example:
<STYLE TYPE="text/css">
@import url(http://www.myserver.com/style.css);
</STYLE>
• Put navigational aids at the top and bottom of each Web page so that the user can easily
move around your site.
• Limit your graphics. Many folks are still using slow connections, so keep graphics
down to 50K or less.
• Indicate to the user that a particular link leaves your Web site. You can use a special
icon next to the link.
• If you're using frames on your site, provide an alternative to the user who has a
frameless browser.
• Design your Web pages for 640x480 resolution. Yes, people still use monitors at that
resolution.
The <LINK> tag's TITLE attribute allows you to name the style sheet. If you don't assign a value to
TITLE, the style sheet is persistent, and the user can't disable it (unless he disables style sheets
altogether). Assigning a value to TITLE changes the style sheet to default, and the user can choose
from any number of named style sheets.
The browser combines any style sheets with the same title that have the alternate keyword attached
to the REL attribute. In the following example, the browser applies the styles in both FIRST.CSS and
SECOND.CSS because both <LINK> tags assign alternate to REL and have the same title.
• The author's style sheet overrides the user's style sheet, whereas the user's style sheet
overrides the browser's default values.
• Inline styles take precedence over embedded style sheets, whereas embedded style
sheets take precedence over linked style sheets.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
198
Shree M .& N. Virani Science College
You can also override the precedence for a rule by using the important keyword. In the following
example, the assignment of red to the property color and the assignment of sans-serif to the
property font-family are marked as important. Thus, the browser will not override these styles. If
two competing style sheets mark the same property as important, however, the rules in the previous list
apply.
HTML 4.0 style sheets give you the opportunity to specify the type of media for which a style sheet is
intended. The browser uses the style sheet that's associated with the media on which the user is
viewing the document. For example, you can associate three style sheets with an HTML document.
The browser uses the first one if a user views the document on the screen, the second one for printing,
and the third one for speech.
To associate a style sheet with a media type, you use the <STYLE> tag's MEDIA attribute. In the
following example, you see two different style sheets. The browser uses the first one for the screen and
the second for printing.
Table 17.1 describes the media types that HTML 4.0 supports.
Linked and embedded style sheets allow you to define styles for one or more individual tags. For
example, you can create a style sheet that defines styles for the <H1>, <H2>, <P>, and <EM> tags. Each
style definition is called a rule. A rule contains a selector (the HTML tag), followed by the declaration
(the definition of the style). The rule's selector ties the style's definition to tags you use in the HTML
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
199
Shree M .& N. Virani Science College
file. The following is an example of what a rule that defines a style for each occurrence of the <H1> tag
looks like:
H1 {color: blue}
The declaration is enclosed in curly braces ({}). Each item in the declaration has two parts: the
property name and the value you're assigning to the property, separated by a colon (:). In the previous
example, color is the property name, and blue is the value you're assigning to it. HTML predefines
dozens of property names (font-size, font-style, color, margin-right, and so on), which you'll
learn about in Appendix B. Each property also accepts a predefined type and range of values.
The following example shows you a few rules contained within an embedded style sheet:
<STYLE TYPE="text/css">
H1 {color: blue}
P {font-size: 10pt}
</STYLE>
You can set multiple properties within a single declaration. You do this by separating each assignment
with a semicolon (;):
In this example, the browser displays each occurrence of the <H1> tag using the color blue, font size of
12 points, and centered in the browser window. For all other properties, the browser uses its default
values. For example, it sets the font-style property to normal.
If you want to define a similar style for several tags, you can list them individually in your style sheet,
like this:
P {font-size: 12pt}
UL {font-size: 12pt}
LI {font-size: 12pt}
You can group the selectors together, however, and define a rule for them as a group. The following
example groups the selectors in the previous example on one line and defines a rule that sets the font-
size property to 12pt:
Note the comma between each selector in the list. Omitting this comma means a totally different thing
(see the following section, "Defining Parent-Child Relationships in Rules," later in this chapter).
Contextual selectors define the exact sequence of tags for which a style will be applied. In other words,
you can specify that a style applies to a particular tag, such as <LI> only if it's a child of the <OL> tag,
like this:
OL LI {list-style-type: decimal}
You can also specify that a particular style applies to the <LI> tag only if it's a child of the <UL> tag,
like this:
UL LI {list-style-type: square}
Note the list of selectors is not comma separated. Separating each selector with a comma would cause
all the tags in the list to be assigned the rule.
Understanding Inheritance
In HTML, tags inherit certain properties from their parents. For example, all the tags within the
<BODY> tag (<P> and <UL>) inherit certain properties from the <BODY> tag. Likewise, the <LI> tag
inherits properties from the <UL> tag that contains it.
Consider the following bit of HTML:
<STYLE TYPE="text/css">
P {color: blue}
</STYLE>
<BODY>
<P>Hello. This is a paragraph of text. <EM>This text is emphasized</EM> </P>
</BODY>
The style sheet for this example sets the color for the <P> tag to blue. There is no definition for the
<EM> tag. You might expect the text in the <EM> tag to change back to the default color: black. That's
not the case. Because the <EM> is within the container tag <P> (it's a child, in other words), the <EM> tag
inherits the color property from the <P> tag.
A class defines a variation of style, which you refer to in a specific occurrence of a tag using the CLASS
attribute. For example, you can define three variations of the H1 style and then use each one in the
appropriate context. You define a class much like you normally define a style, only you add an
arbitrary class name to the end of the tag, separating them with a period, as in the following example:
Then, when adding the <H1> tag to your HTML document, you set the CLASS attribute to indicate
exactly which style you're using:
TIP: You can address all the tags within a particular class by omitting the tag name from the selector,
like this: .red {color: red}. After defining this style, any tag that you associate with the red class,
will be displayed using the color red.
You can use an inline style to define how a particular element looks by assigning the style to the
element's STYLE attribute. You can make your HTML document easier to read, however, by giving an
element an ID; then you associate a style with that element using its ID.
For example, the following <P> tag assigns test to the ID attribute:
You can define a rule that affects only that element by using the its ID as the selector for the rule,
prefixed with a pound sign (#), like this:
CSS defines a concept called pseudo-classes, which are special selectors that define how certain
HTML elements look at certain times. For example, CSS defines a pseudo-class that defines how an
anchor looks when the user clicks on it or how the first line of a paragraph looks. In general, pseudo-
classes look like the following example.
CSS1 defines three pseudo-classes for anchors: link, active, and visited. When you use these
pseudo-classes with the A selector in a style rule, you're defining how a normal, active, and already
visited link looks on the Web page. For instance, the following example defines unvisited links as blue,
active links as red, and visited links as yellow:
CSS1 defines a pseudo-class for the first line of a paragraph. Any style rule you assign to the selector
called first-line applies to the first line of that element. If you use the first-line pseudo-class
with the <P> tag, for example, the first line of each paragraph uses the formatting you specified in the
rule. The following example causes the first line of every paragraph to be bold:
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
202
Shree M .& N. Virani Science College
P:first-line {font-weight: bold}
Similarly, you can change the formatting for the first letter in an element using the first-letter
pseudo-class. This is handy to create special effects such as drop-caps:
If your style sheet gets complicated or you need to explain why you've made a particular design
decision, you can add a comment to the style sheet. Comments only serve to document your style
sheet; they don't have any impact on how the browser displays the HTML document.
Enclose your comments between /* and */. The following example shows you what a one-line
comment looks like:
You can also use the /* and */ characters to create block comments. This is useful to explain an entire
portion of your style sheet. Like this:
/*----------------------------------------------------------------
The margin-left property is set to one inch for the BODY tag.
Since all of its enclosed tags will inherit this setting, the
entire page will appear to be indented by one inch. The first-
and second-level headings are indented to the left by one inch
so that they slide out into the margin.
--------------------------------------------------------------*/
BODY {margin-left: 1in} /* Create space for sliders */
H1 {font-size: 16; margin-left: -1in} /* Out one inch */
H2 {font-size: 14; margin-left: -1in} /* Out one inch */
HTML style sheets are new. Internet Explorer and Netscape are the first browsers to support them.
You need to worry about all those browsers that don't support style sheets, however.
Most browsers are designed to simply ignore the tags and attributes they don't understand. Thus, they'll
ignore the <STYLE> tag, for example. They won't necessarily ignore what you put in the <STYLE> tag,
though, and will display its contents as text on the Web page. To get around this problem, you can use
an HTML comment within the <STYLE> tag to hide the style definitions, like this:
<STYLE TYPE="text/css">
<!--
H1 {color: red}
-->
</STYLE>
Browsers that don't support style sheets display the HTML files with their default
styles. They'll ignore the style definitions.
Chapter 16
Positioning HTML Elements
In the desktop publishing world, layers are rectangular blocks of text and artwork that you can position
anywhere on the page. You can also overlap layers so that one is hidden behind another or so that one
bleeds through another. Publishers use layers to create some pretty awesome layouts. Take a look at
any print advertisements or brochures, for example. Chances are, the publisher used layers.
While desktop publishers might take layering for granted (even the simplest of desktop publishing
programs allow you to create and overlap layers), HTML designers don't. Because HTML is
streaming, they've never had the capability to overlap blocks of text and artwork. That is, each
preceding HTML element is displayed before the next--in order. HTML has never provided for the
positioning of an HTML element, much less for overlapping HTML elements.
Until now--HTML 4.0 introduces the CSS positioning. If you're unsure of how to use style sheets, you
should review Chapter 17, "Applying Cascading Style Sheets."
You define an element's position using a style. Within a style's rule, you assign either RELATIVE or
ABSOLUTE to the POSITION property. If you assign RELATIVE, the browser positions the element
relative to its normal position (the location at which it would naturally appear). If you assign ABSOLUTE
to POSITION, the browser positions the element relative to the parent container, whether it be the
document or some other element, such as a <DIV> tag. In most cases, you use ABSOLUTE to place an
element at an exact location relative to its parent. Use RELATIVE if you want to nudge an element
slightly out of its normal location.
You position an element using a style's TOP and LEFT properties, like this:
When you assign the example style to an element, the browser positions it 100 pixels down and 20
pixels to the right of document's top, left-hand corner.
LEFT and TOP are represented in pixels, by default, and are relative to the top, left corner of the
containing area within the HTML document. For example, to position an element 10 pixels from the
left edge of the browser window and 40 pixels from the top edge, use LEFT=10 and TOP=40. The
browser draws the HTML document as though the positioned element does not exist, and then the
element is overlapped with the Web page at the given offset. You can also assign percentages to LEFT
and TOP, which represent a percentage of the parent container's width and height, respectively. Listing
18.1 positions an element in the middle of the Web page. As shown in Figure 18.1, the contents of the
HTML document bleed through the contents of the positioned element because it's transparent.
You can change the height and width of the rectangular area occupied by an element. You use the
WIDTH and HEIGHT properties. Like TOP and LEFT, you can assign a length or percentage to either of
these properties. You can also assign AUTO to them and the browser automatically determines the
appropriate width and height.
#element {position: absolute; top: 20; left: 20; width: 100; height: 100}
You don't use the WIDTH attribute to define the element's absolute width. This property suggests a
width for purposes of wrapping the text contained within the element. If the text doesn't completely fill
the element, however, the element is not actually as wide as the specified value. If you're inserting an
image (or another element the browser can't wrap) inside an element, and the image is wider than the
suggested width, the element's actual width is bigger than the suggested value.
TIP: The OVERFLOW property determines what the browser does in the case that an element's contents
are larger than the element's size. Assign NONE, and the contents are not clipped. Assign CLIP, and the
browser chops off the content to fit in the rectangular area. Assign SCROLL, and the browser allows you
to scroll the window so you can see more of it.
Listing 18.2 shows an example of an element that is 160 pixels wide and positioned 80 pixels from the
top. As shown in Figure 18.2, the text wraps within the element, just like it would wrap within a table
cell that's 160 pixels wide.
TIP: You can use positioned elements to perform many of the same formatting tricks you've learned to
do with the <TABLE> tag.
You can cause elements to overlap by setting each element's TOP and LEFT attributes so that one
appears on top of another. Figure 18.3 shows two elements. The first contains a handful of text and has
a background image. The second element contains an image with a transparent background. The
second element is positioned so that it overlaps the first (see Listing 18.3).
NOTE: By default, the browser draws overlapped elements in the order it encounters them. That is, it
draws the first element, overlaps that with the next element, and so on.
You set this attribute to any positive integer value. An element with a stacking order larger than
another draws over the other element. For example, an element with a stacking order of 10 overlaps an
element with a stacking order of five. On the other hand, an element with a stacking order of three is
overlapped by an element with a stacking order of five.
Listing 18.4 is an example of three elements, each of which uses the Z-INDEX attribute to define its
stacking order. The first has a stacking order of two; the second has a stacking order of one, and the
third has a stacking order of three. Thus, the browser draws the second element first, the first element
second, and the third element last, as shown in Figure 18.4.
TIP: You can overlap several elements at the same position, define each element's stacking order in
sequence, and then peel away the elements one at a time (using a script) to create a simple animation.
So far, you've only seen cases in which a handful of elements were added to the HTML document.
They were siblings in that one was not contained within another. You can insert one element inside
another, however, to create a parent-child relationship. In that case, the child (inside) is relative to the
parent (outside). Thus, if you position an element called PARENT and locate it at 10, 10; and nest an
element inside of PARENT called CHILD located at 5, 5; the child element actually displays at 15, 15 on
the HTML document. If you move the parent element to 20, 20, the child element moves right along
with it to 25, 25.
Listing 18.5 shows you an example of nested elements. The parent element contains an image of a
rough Christmas tree. It contains a number of nested elements that represent bulbs. The coordinates of
each nested element are relative to the upper-left corner of the parent. If you moved the Christmas tree
to another location on the Web page, the bulbs would move right along with it (see Figure 18.5).
You get a lot of publishing capabilities just from being able to position an element anywhere on an
HTML document and overlap it with others. You can create a variety of special effects, however, by
attaching a script to an element and using that script to hide or show it--you can even move it around
the browser window.
Given an element's ID, you reference it using the object model (see Chapter 19, "Scripting the Object
Model"), like this:
document.all.item(id, 0)
id is the element's ID. The 0 indicates that you want the first occurrence of any element with that
particular ID.
document.all.item(id, 0).style.property
You can use a script to hide and show elements on the HTML document. For example, you can create
an element that you only want to display when the user moves the mouse across an image. In that case,
you'd set the element's VISIBILITY property to "hidden" so that it's not initially displayed. Then, in
the image's OnMouseOver event, set the element's visibility property to "", like this:
Listing 18.6 shows you an example that does something similar. It uses JavaScript, but you can use
another scripting language just as well. It contains three elements and three buttons. The script
associated with each button toggles the visibility of each element. Click a button associated with a
visible element and the script makes the element invisible (see Figure 18.6).
Take a look at the function called ToggleFirst(). It toggles the state of the flag called ShowFirst,
which indicates whether the element called FIRST is visible. It then sets the element's visibility
property to "hidden" if ShowFirst is false; otherwise, it sets the property to "", which causes the
element to become visible.
TIP: In Windows, you've seen dialog boxes that contain a button with the text More>>. When you
click that button, additional fields are presented. You can achieve the same effect in an HTML form by
attaching a script to a form's button that shows another form hidden within a <DIV> tag.
Besides showing and hiding an element, you can also move it around on the Web page. You can use
this to create some pretty fancy animation, such as a curtain that appears to open, unveiling the
contents of the page. Moving an element around is easy. You set the value of the left and top
properties (using posLeft and posTop so that you don't have to change the length as a string with
units), as shown in Listing 18.7 and Figure 18.7.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
211
Shree M .& N. Virani Science College
This example contains two elements. It also contains four buttons, label Up, Down, Left, and Right.
Each button is associated with a function that moves the second element in the appropriate direction.
For example, the Up function subtracts 10 from the second element's top property, which has the effect
of moving the element up 10 pixels. The Right function adds 10 to the second element's left
property, which has the effect of moving the element right 10 pixels.
There are two types of users in this world: basic and advanced. With forms, you find many cases in
which a basic user needs to fill in only a few of the simpler fields, while the advanced user needs to fill
in all of the fields, including the more advanced fields.
You can display all of the form's fields at one time and let the basic user ignore the advanced fields or
you can hide the advanced fields and let the advanced user get to them by clicking a special button.
The latter is the approach that Windows 95 and Windows NT 4.0 take in many cases. Have you ever
seen a dialog box in Windows with a button labeled Advanced or More? When the user clicks one of
these buttons, the dialog box unfolds to show more fields.
With CSS positioning, hiding a portion of a form until a user clicks a button is easy. Listing 18.8 is just
such an example. At the bottom of this HTML document, you see a portion of the form sandwiched in
a <DIV> tag. The <DIV> tag's visibility property is initially set to "hidden". The function OpenMore
toggles the visibility of the hidden portion of the form and changes the text displayed in the button to
reflect the state of the form.
Appendix
HTML Tags
There are many HTML elements, and each has its own set of attributes that it can use. This is a
complete list of HTML tags, their corresponding attributes, and a description of what they do.
You can put in a comment in your Web document by enclosing it between the <!-- beginning marker,
and the --> ending marker. Some browsers will not properly handle HTML-related characters within
the comments. Also, not all browsers correctly recognize the double dashes as being needed for the
start of the comment. This HTML tag has no attributes.
<!-- This line of text will only be seen by people who look at the HTML source. --
>
<A>: Anchor
The Anchor HTML tag is an important element for hypertext links of any sort. The Anchor element
type can have the following attributes:
<ABBREV>: Abbreviations
The proposed Abbreviations tag will change some of the enclosed text into abbreviations. This does
not change the actual text, just how it's displayed by the browser. This is a work in progress. The
Abbreviations tag can have the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<ACRONYM>: Acronym
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<ADDRESS>: Address
The <ADDRESS> tag is used to indicate an address, typically the e-mail address of the Web author.
The Address element can have the following attributes:
• ALIGN-This is a proposed attribute to HTML for internationalization. It's used to indicate the
alignment of the text in the address. It can have the value of center, justify, left, or right.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• NOWRAP-This is a proposed attribute to HTML 3 to indicate that the address should not be word
wrapped.
This proposed HTML extension was introduced in Netscape Navigator. When used, browsers that can
run JAVA applications will run the specified JAVA applet. Parameters that you want to pass to a
• ALT-This attribute indicates to browsers that recognize the <APPLET> tag an alternate text
string to be displayed. This behaves the same as the ALT attribute for the <IMG> tag.
• ALIGN-This attribute indicates the display alignment of the JAVA applet. It can have the
following values: absbottom, absmiddle, baseline, bottom, left, middle, right, texttop,
and top.
• CODE-This indicates the file that contains the JAVA applet program. The file name indicated
cannot point to an absolute URL.
• CODEBASE-You specify the base URL for the JAVA application with this attribute. This is used
in conjunction with the CODE attribute.
• HEIGHT-This indicates the initial height of the display for the JAVA applet. The value must be
specified as the number of pixels.
• HSPACE-This indicates how many pixels to reserve for the JAVA applet, horizontally.
• NAME-This attribute gives a name to the JAVA applet that is about to be executed. This is useful
when you want different applets on the same Web page to talk to each other.
• VSPACE-This indicates how many pixels to reserve for the JAVA applet, horizontally.
• WIDTH-This indicates the initial width of the display for the JAVA applet. The value must be
specified as the number of pixels.
This proposed extension to HTML by Netscape is used to create client-side imagemaps. This tag is
intended to specify one clickable region on a graphic. <AREA> has the following attributes:
• ALT-This provides a text-based alternative to non-graphical Web browsers. Currently, this has
not been defined.
• COORDS-This indicates the position of the specified area on the image. The coordinates are put
in quotation marks, and the coordinates are separated by commas. The upper left-hand corner
of the image is "0,0".
• HREF-This specifies the destination URL if this area is accessed.
• NOHREF-This is used to indicate that a region isn't linked to anything.
• SHAPE-This is used to indicate the shape of the clickable region. If this attribute is rect, then
COORDS must indicate the coordinates for the upper-left corner followed by the lower-right
corner. For the circle value, COORD indicates the coordinates of the center followed by the
radius. As for the polygon value, COORD indicates a successive set of coordinates. Each pair of
coordinates indicates a vertex of the polygon.
<AU>: Author
This proposed HTML 3 tag is used to indicate the name of an author. <AU> can have the following
attributes:
The authors of this book are <AU>Mark Brown and John Jung</AU>.
<B>: Bold
This tag will make whatever text is enclosed within it display in a bold font. The <B> tag can have the
following attributes:
<BANNER>: Banner
This is a proposed HTML 3 tag that will display something as a banner. The text in this tag will not
scroll with the rest of the HTML document. It's mainly intended to be used for company logos or
navigational aids. You can use the following attributes:
The <BASE> HTML element is used to indicate the default location of relative URL links. This is
useful in the event that you move your home page to another computer. If this happens, all relative
links on that page will not have to be updated. This tag can have the following attributes:
• HREF-This indicates the baseline URL that relative links will be based upon.
• TARGET-This indicates the name of the window to be used when going to the hypertext link. If
the window doesn't exist, the browser will open up a new window and assign it that name. This
attribute is an extension introduced by Netscape.
<BASE HREF="http://www.mycomputer.com/homepage/mystuff/">
This HTML element is used to indicate the default font size for the current HTML document.
<BASEFONT> was originally introduced as an extension by Netscape. It has only one attribute: SIZE.
This attribute indicates which default font value to use. By default, the font value used is 3. There are
seven possible values for this attribute: 1, 2, 3, 4, 5, 6, and 7. These do not indicate point sizes, but
rather a predetermined font size.
<BASEFONT SIZE=4>
This proposed tag is intended for the internationalization of HTML. The <BDO> tag is used to indicate
how text should be displayed by the browser. It has the following attributes:
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
221
Shree M .& N. Virani Science College
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<BDO DIR=ltr>This will cause text to flow from the left to the
Microsoft introduced this proposed extension to HTML for adding more flair to home pages. This will
cause a sound file to be played in the background while the user is looking at the home page. This tag
can have the following attributes:
• LOOP-This indicates how many times the sound file should be played. This can either be a
numerical value or the word infinite. If no value is specified, the sound file is played once.
• SRC-This attribute indicates the URL for the sound file to be played. Available sound file
formats are .WAV, .AU, and .MID.
<BGSOUND SRC=http://www.mysite.com/intro.wav>
<BIG>: Big
This is a proposed HTML 3 tag that instructs the browser to make the enclosed text big. This can have
the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<BLINK>: Blink
This HTML tag will cause the enclosed text to blink. This tag was introduced by Netscape as a
proposed extension. Some people find the <BLINK> tag to be quite annoying.
<BLOCKQUOTE>: Blockquote
When a browser comes across this HTML tag, it will show the text as quoted text. This typically
means that the text will be indented on both the left and right. <BLOCKQUOTE> can have the
following attributes:
• ALIGN-This is a proposed attribute to HTML for internationalization. It's used to indicate the
alignment of the text in the address. It can have the value of center, justify, left, or right.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<BODY>: Body
This HTML tag encloses the body of the Web page. Everything you want users to see is enclosed
within the <BODY> tag. This element can have the following attributes:
• ALINK-This Netscape extension indicates the color to be used when a link is clicked. This color
is represented by three pairs of hexadecimal numbers. The pairs represent the red, green, and
blue color values.
• BACKGROUND-This Netscape extension provides for a background image. This extension has also
been proposed for HTML 3. The value you set for this must be the URL for the graphic you
want displayed in the background.
• BGCOLOR-This Netscape extension indicates the color of the background for this page. This
color is represented by three pairs of hexadecimal numbers. The pairs represent the red, green,
and blue color values.
• BGPROPERTIES-This is a Microsoft extension and can currently only be set to fixed. It provides
for a background watermark image.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
<BQ>: BlockQuote
This is a proposed HTML 3 element that is intended to replace the <BLOCKQUOTE> tag. <BQ> is
different from <BLOCKQUOTE> in that it does not imply word wrapping. This tag has the following
attributes:
This HTML tag forces a new line to be created at that point. This means that whether or not word wrap
will take effect, the line break will occur. This element has the following attributes:
<CAPTION>: Caption
This HTML 3 proposed tag was originally a Netscape proposed extension. This element is used to
attach a label to a table or a figure. <CAPTION> has the following attributes:
• ALIGN-This attribute will determine where the caption is placed. Acceptable values are top,
bottom, left, and right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<CAPTION>Table 1.1</CAPTION>
<CENTER>: Center
This Netscape-specific extension to HTML will center all enclosed text. This has since been
superseded by the HTML 3 proposals. Now, all text elements have an ALIGN attribute that can be set to
center.
Example:
<CITE>: Citation
The CITE element is used when you want to indicate a citation of some sort. It has the following
attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
Example:
The <CODE> element should be used when you want to indicate source code. If you're giving people
instructions on how to do something with a computer, use this tag. You can use the following
attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
There is a new proposed HTML 3 standard for table creation. One of the new tags included in that
proposal is the <COL> element. You can use this element to define some standard behavior for table
columns. This tag has the following attributes:
The <COLGROUP> element is a container for a group of columns. It also enables you to set the
defaults for all of these columns. This element has the following attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, center, justify, left, or right.
• CHAR-This is used to indicate which character the column is to be aligned with. This is only
interpreted when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
<CREDIT>: Credit
This HTML 3 proposed tag should be used to name the source of information. The following attributes
are available:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
If you choose to make use of a definition list in your home page, you'll need <DD>. This HTML tag is
used to indicate a definition for the definition list. A <DD> tag should always be preceded by a <DT>
tag. The <DD> element has the following attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
228
Shree M .& N. Virani Science College
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<DD>Sample Definition</DD>
<DEL>: Delete
This HTML 3 tag is meant to supersede the <S> or <STRIKE> elements. Text enclosed within a
<DEL> tag will be shown as strikethrough. You have the following attributes available:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This is a <DEL>mistake<DEL>.
<DFN>: Definition
This HTML 3 tag will have the browser display the enclosed text as a description. If the current Web
page makes use of a lot of definitions, you should use this tag. This element has the following attribute:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
The <DIR> element is used when you want to create an unordered list of single-line elements. Each
line in the <DIR> list is defined by the <LI> tag. You can apply the following attributes to the <DIR>
tag:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• COMPACT-This attribute tells the browser to display the list in a compact manner. It is not,
however, supported by many browsers.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<DIR ALIGN=center><LI>MYFILE.EXE</LI><LI>MYFILE.TXT</LI></DIR>
This proposed HTML 3 tag is intended to be used to replace the Netscape-specific <CENTER> tag. It
has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
If you're going to use a lot of definitions or have a page of definitions, you need this tag. Each entry in
the definition list is made up of <DT> and <DD> tags. You can use the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• COMPACT-This attribute tells the browser to display the list in a compact manner. It is not,
however, supported by many browsers.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This is one of the three HTML elements you need to use when creating a definition list. You create
headings for your definitions with the <DT> tag. This HTML element comes with the following
attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<DT>Definiton Heading</DT>
<EM>: Emphasis
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
Netscape Navigator 2.0 provides for the capability to insert arbitrary objects. This is done with the
newly created Netscape-specific tag, <EMBED>. You have a number of attributes you can use:
<EMBED SRC="mymovie.dcr">
<FIG>: Figure
A new element in the HTML 3 proposal is the <FIG> tag, an improved <IMG> tag. You can include
text elements as well as specify hotspots with other tags. You can also use the <OVERLAY> element
to put overlays on top of figures. <FIG> has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
bleedleft, bleedright, center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
232
Shree M .& N. Virani Science College
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• HEIGHT-This indicates the initial height of the display for the embedded object. The value must
be specified as a number of pixels.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used in conjunction with the SRC attribute, to specify a message digest or checksum. This is
used when you want to be sure that a linked object is the one the Web author specified.
• SRC-This points to an URL for the image you want to use.
• UNITS-This attribute enables the HEIGHT and WIDTH attributes to use units other than screen
pixels.
• WIDTH-This indicates the initial width of the display for the embedded object. The value must
be specified as a number of pixels.
<FIG SRC="http://www.mysite.com/mygraphic.gif"></FIG>
<FN>: Footnote
A new proposed HTML 3 tag is the footnote element. Currently, very few browsers support this tag.
You have the following attributes available:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<FN>This is a footnote.</FN>
The <FONT> element, first introduced by Netscape, enables various font manipulations. It has not
been adopted as part of the new HTML 3 proposal. <FONT> has the following attributes:
• COLOR-This attribute enables the font to be drawn in a particular color. This color is represented
by three pairs of hexadecimal numbers. The pairs represent the red, green, and blue color
values.
• FACE-This attribute was introduced by Microsoft as a means of specifying a font style. There
are currently no defined values.
• SIZE-This attribute indicates how much to increase or decrease the <BASEFONT> size. An
acceptable value is anything between -7 and +7. You can also specify an absolute font size,
with acceptables values between 1-7.
<FONT SIZE=+2>
The fill-out form is one of the best ways to get user input. The biggest drawback to using <FORM> is
that you must have a CGI script to retrieve the information. Here is a list of attributes for this tag:
<FRAME>: Frame
The <FRAMESET> tag is another proposed extension from Netscape to be used instead of the
<BODY> element. This tag is used only to set up other frames that will be the actual page. You must
use the <FRAME> element if you use this tag. You have a number of attributes available:
• COLS-This list of widths of the frame is separated by commas. By default, you specify the frame
widths in pixels. Alternatively, you can add the percent sign (%) after a number to make the
frame width a percentage of the browser's width.
• ROWS-This attribute is similar to the COLS attribute, except that it applies to the frames' heights.
These values for each consecutive frame are separated by commas. By default, the height
specifications are expressed in screen pixels. Alternatively, you can add the percent sign (%)
after a number to make the frame height a percentage of the browser's height.
This HTML tag displays text as the most prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
235
Shree M .& N. Virani Science College
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used to specify a message digest or checksum. This is used when you want to be sure that a
linked object is the one the Web author specified.
• NOWRAP-When used, this attribute will prevent the browser from word wrapping the heading.
This HTML tag displays text as the second most prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used to specify a message digest or checksum. This is used when you want to be sure that a
linked object is the one the Web author specified.
• NOWRAP-When used, this attribute will prevent the browser from word wrapping the heading.
This HTML tag displays text as the third most prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used to specify a message digest or checksum. This is used when you want to be sure that a
linked object is the one the Web author specified.
• NOWRAP-When used, this attribute will prevent the browser from word wrapping the heading.
This HTML tag displays text as the fourth most prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
This HTML tag displays text as the fifth most prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, left, right, or justify.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used to specify a message digest or checksum. This is used when you want to be sure that a
linked object is the one the Web author specified.
• NOWRAP-When used, this attribute will prevent the browser from word wrapping the heading.
This HTML tag displays text as the least prominent header. It has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, left, right, or justify.
<HEAD>: Head
This element is intended to hold information about the HTML document. Although you can put other
HTML elements within the <HEAD>, none of them will be displayed in the browser's window. This
tag has the following attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
When used, the <HR> tag creates a horizontal line. It has the following attributes:
• ALIGN-This proposed extended attribute indicates the positioning of the rule. It can have the
value of left, right, center, or justify.
<HTML>: HTML
This is the main container for a home page. All other HTML tags contained within this element are
shown in the browser window. This tag has the following attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<I>: Italic
This tag will italicize the text that is enclosed within it. The <I> tag can have the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<IMG>: Image
Currently, any time you want to make use of graphics on your home page, you have to employ the
<IMG> tag. This element enables you to specify imagemap information, hypertext link information,
and positioning information. It has the following attributes
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
absbottom, absmiddle, baseline, bottom, left, middle, right, texttop, or top.
• ALT-This attribute contains a text string that will be displayed by people who aren't using
graphical browsers.
• BORDER-This attribute indicates the thickness of the border around the image. The unit of
measurement for the thickness is determined by the UNITS attribute.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CONTROLS-This is a Microsoft proposed attribute extension. If a video file is specified by the
SRC attribute, a set of controls is displayed under the video clip.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• DYNSRC-This is a Microsoft proposed attribute extension that points to an URL. The URL is a
video clip or VRML world to be displayed.
• HEIGHT-This indicates the initial height of the display for the embedded object. The value must
be specified as a number of pixels.
• HSPACE-This Netscape proposed extension controls the amount of horizontal space around the
image. The value specified is expressed as a number of pixels.
<INPUT>: Input
This HTML 3 proposed element works with the FORM element. The <INPUT> tag enables the user to
upload a file through the Web server. It has the following attributes:
• ACCEPT-This attribute indicates a list of media types that the server will accept.
• ALIGN-This attribute indicates the alignment of the <INPUT> form. Acceptable values for this
attribute are bottom, left, middle, right, and top.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
242
Shree M .& N. Virani Science College
• CHECKED-This indicates that the specific form will be a check box. If this is not specified, it will
default to a radio button.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• DISABLED-This proposed HTML 3 attribute will display the form, but prevent the user from
modifying it.
• ERROR-This proposed HTML 3 attribute is used when an incorrect value is entered. The text
specified in this attribute is displayed on invalid input.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MAX-This value is only used when the TYPE attribute is set to RANGE. This indicates the
acceptable maximum numeric value.
• MAXLENGTH-This proposed HTML 3 attribute specifies the maximum number of characters
acceptable for input.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used in conjunction with the SRC attribute, to specify a message digest or checksum. This is
used when you want to be sure that a linked object is the one the Web author specified.
• MIN-This value is only used when the TYPE attribute is set to RANGE. This indicates the
acceptable minimum numeric value.
• NAME-The string in this attribute is the name for the input form.
• SIZE-This attribute specifies the physical size of the input form. This value is specified in
number of characters.
• SRC-When the TYPE attribute is set to IMAGE, this points to an URL. When the user clicks the
image and the form is submitted, the mouse coordinates are sent over as well. This is similar to
having a form-based imagemap.
• TYPE-This attribute indicates the behavior of the INPUT form. Acceptable values are
CHECKBOX, FILE, HIDDEN, IMAGE, JOT, PASSWORD, RADIO, RANGE, RESET, SCRIBBLE, SUBMIT, or
TEXT.
• VALUE-This attribute changes based on the TYPE attribute. Generally speaking, the VALUE
attribute will contain the value returned by the user.
<INS>: Insert
This proposed HTML 3 element will display the enclosed text as inserted text. The text embedded by
the starting and ending markers of this element, will be shown in a strikethrough font. This tag is
mainly intended for legal documents and has the following attributes:
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
243
Shree M .& N. Virani Science College
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This HTML element is used before the <FORM> tag to indicate a searchable index. When this tag is
put in the HEAD section of the HTML document, the entire document can be examined using a keyword
search. <ISINDEX> has the following attributes:
• ACTION-When <ISINDEX> is used in the <BODY> portion of the Web document, this points
to a CGI script. The script is the program on the server that can handle the search.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• PROMPT-This is a proposed HTML 3 attribute that enables the Web author to specify a prompt.
The string assigned to this attribute will be displayed as the prompt, for the searchable index.
<ISINDEX>
<KBD>: Keyboard
This HTML element will cause the enclosed text to be displayed as keyboard input. This is typically
done when you want to give users instructions on what to type into the computer. This tag has the
following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
This is a proposed HTML 3 attribute that changes the LANG context. The text enclosed within this tag
will have its LANG context changed, as well as all subsequent LANGs. This tag has the following
attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
This proposed HTML 3 element enables you to define the header for a list. This tag has the following
attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This attribute takes the enclosed text and makes it part of the list. This element has the following
attributes:
• ALIGN-This attribute specifies the alignment of the list item. You can set it to the value of
center, justify, left, or right.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• TYPE-This Netscape extension enables you to specify the prefix for this particular item. If
you're using a <UL> list type, TYPE can be circle, disc, or square. If the list is an <OL> list
type, TYPE can be A, a, I, i, or 1.
• VALUE-This Netscape extension works with the TYPE attribute. When you specify an <OL> list
type, this attribute indicates the starting number of the list. By default, this value is 1.
<LINK>: Link
This HTML tag is used to specify a relationship between the current Web page and other HTML
documents. This element is used along with the Anchor attribute REL. This element has the following
attributes:
<LINK HREF="http://www.mysite.com/destination1.html">
This Netscape proposed HTML element describes imagemap regions. The one attribute allowed is
NAME, which points to a file with the imagemap regions defined.
<MAP NAME="myregions.map"></MAP>
<MARQUEE>: Marquee
This HTML element proposed by Microsoft will create an area with scrolling text inside of it. The text
to be scrolled is contained within the start and end markers of this element. This tag has the following
attributes:
• ALIGN-This attribute specifies how the text will be displayed in the marquee. You can set it to
the value of bottom, middle, or top.
• BEHAVIOR-This attribute determines whether the text will scroll completely off the marquee.
You can set this attribute to alternate, scroll, or slide. The alternate value will cause the
text to move back and forth from side to side. The text will scroll completely off the marquee
when the value is scroll. The text in the marquee will enter the marquee and stay there with
the slide value. The default is scroll.
• BGCOLOR-The background color of the marquee can be specified with this attribute. The color is
represented by three pairs of hexadecimal numbers. The pairs represent the red, green, and blue
color values.
• DIRECTION-This attribute indicates how the text will scroll in the marquee. You can either set
this to left or right.
• HEIGHT-The height of the marquee is controlled with this attribute. You can specify the size in
either pixels or as a percentage of the window height. If you're specifying a percentage of the
window, you'll need to add a percent sign (%) after the number.
• HSPACE-This attribute defines how many pixels separate the marquee from surrounding text.
This controls the amount of pixels to use as a buffer horizontally.
• LOOP-This number specifies how many times the marquee text will loop. A value of -1 or the
string INFINITE will cause the text to loop forever.
• SCROLLAMOUNT-This number determines the number of pixels to scroll the marquee text.
• SCROLLDELAY-You can specify the number of milliseconds between marquee updates with this
value.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
247
Shree M .& N. Virani Science College
• VSPACE-This attribute defines how many pixels separate the marquee from the surrounding text.
This controls the number of pixels to use as a buffer vertically.
<MENU>: Menu
This HTML element will display any <LI> enclosed within it in a menu list. HTML 3 proposed to
remove this element. This tag has the following attributes:
• ALIGN-This attribute specifies the alignment of the list item. You can set it to be the value of
center, justify, left, or right.
• COMPACT-This attribute causes the menu list to be displayed in a physically compact form.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This HTML tag is intended to specify document information not available with other HTML elements.
The information contained in this element may be extracted by the server or the browser. This tag has
the following attributes:
• CONTENT-This attribute specifies the meta-information to be associated with the value in the
NAME attribute. You can also use this attribute to indicate the information to be associated with
an HTTP response header. If the HTTP-EQUIV attribute is set to the Netscape-specific REFRESH,
Then CONTENT will indicate the number of seconds to update the current Web page.
• HTTP-EQUIV-You specify which attribute to associate the <META> element with. Netscape
introduced the value of REFRESH to enable home pages to be updated.
• NAME-If the HTTP-EQUIV attribute is not defined, this attribute is used to identify the
information.
• URL-This Netscape attribute extension is used to indicate which home page is to be updated.
After the number of seconds specified in CONTENT, this URL will be reloaded.
This Netscape HTML extension element is intended to be used for browsers that understand, but don't
implement, the <EMBED>/<NOEMBED> tags. If one of these browsers comes across the
<NOEMBED> element, the enclosed text will be displayed. This is basically equivalent to the ALT
attribute for the <IMG> element.
<NOEMBED>You'll only see this if your browser doesn't support the EMBED
tag.</NOEMBED>
This Netscape HTML extension element is intended to be used for browsers that understand, but don't
implement, the <FRAMESET>/<NOFRAMES> tags. If one of these browsers comes across the
<NOFRAMES> element, the enclosed text will be displayed. This is basically equivalent to the ALT
attribute for the <IMG> element.
<NOFRAMES>You'll only see this if your browser doesn't support the FRAMESET
tag.</NOFRAMES>
<NOTE>: Note
This proposed HTML 3 element will cause the enclosed text to be displayed as a note. The <NOTE>
tag has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
249
Shree M .& N. Virani Science College
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used in conjunction with the SRC attribute, to specify a message digest or checksum. This is
used when you want to be sure that a linked object is the one the Web author specified.
• SRC-This points to an URL for an image to be displayed before the <NOTE>.
<NOTE>This is a note.</NOTE>
This HTML element will display any enclosed <LI> elements as an ordered list. The order is listed
numerically. It has the following attributes:
• ALIGN-This attribute specifies the alignment of the list item. You can set it to be the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. In the ordered
list, this indicates what type of numerical sequence to use.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• COMPACT-This attribute causes the menu list to be displayed in a physically compact form.
• CONTINUE-This proposed HTML 3 attribute will continue the numbering sequence. If you've
already started another <OL> list, the numbering will continue with this attribute.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• SEQNUM-This proposed HTML 3 attribute will define the starting number for the ordered list.
• START-This Netscape extension is the equivalent of the SEQNUM attribute.
• TYPE-This Netscape extension is used to indicate the numbering option. You can set this
attribute to A, a, I, i, or 1.
This HTML element identifies a particular selection in the SELECT element. You can set the following
attributes:
<OPTION VALUE="line1"></OPTION>
This proposed HTML 3 tag is intended to be used along with the <FIG> element. The <OVERLAY>
tag enables you to overlay an image on top of a <FIG> image. It has the following attributes:
• HEIGHT-This indicates the initial height of the display for the overlaid image. The value must be
specified as a number of pixels.
• IMAGEMAP-When using imagemaps, you must use this attribute. This indicates that the overlay
is to be treated as imagemap.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used in conjunction with the SRC attribute, to specify a message digest or checksum. This is
used when you want to be sure that a linked object is the one the Web author specified.
• SRC-This points to the image to be overlaid on top of a <FIG>.
• UNITS-This attribute enables the HEIGHT and WIDTH attributes to use units other than screen
pixels.
• WIDTH-This indicates the initial width of the display for the overlaid image. The value must be
specified as a number of pixels.
• X-This value indicates the number of units horizontally offset from the upper-left corner of the
<FIG> graphic. The units used is determined by the UNITS attribute. If UNITS isn't specified,
then the default value for the X attribute is pixels.
• Y-This value indicates the number of units horizontally offset from the upper-left corner of the
<FIG> graphic. The units used is determined by the UNITS attribute. If UNITS isn't specified,
then the default value for the Y attribute is pixels.
This HTML tag will prevent the enclosed text from being word wrapped. The browser will not attempt
to word wrap the text contained in this element. You can set the following attributes:
• ALIGN-This attribute specifies the alignment of the list item. You can set it to the value of
center, justify, left, or right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• NOWRAP-This proposed HTML 3 attribute replaces the NOWRAP attribute. Acceptable values for
this attribute are on or off.
• WRAP-This proposed HTML+ attribute will enable or disable word wrap. If this attribute is
present, the browser will word wrap the enclosed text.
<P>This line of text will always be this long, regardless of the size of the
browser.</P>
This HTML element is proposed to support JAVA applets. It enables the Web author to specify
parameters to be passed to the <APPLET> application. This tag has the following attributes:
<PERSON>: Person
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<PERSON>John Doe</PERSON>
This HTML tag will display the enclosed text as is and in monospaced characters. Normally, text
elements will remove multiple spaces and line breaks to clean up the output. The use of <PRE> will
prevent this. This element has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• WIDTH-This attribute indicates the maximum number of characters per line. Most browsers
ignore this attribute.
<PRE>I can put as many spaces as I want, and they'll all show
up!</PRE>
<Q>: Quotation
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
253
Shree M .& N. Virani Science College
This proposed HTML 3 element will display the enclosed text as a quotation. The LANG context defines
the appropriate quotation marks. There are a number of attributes you can set:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<S>: Strikethrough
This proposed HTML 3 element replaces the <STRIKE> tag. This will display a strikeout line through
the enclosed text. This tag has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<SAMP>: Sample
This element displays the enclosed text as a sampling of text. You have the following attributes
available:
This form element creates a menu of selectable entries. The selectable entries are defined by the
<OPTION> element. The <SELECT> tag has the following attributes:
• ALIGN-This attribute specifies the alignment of the entries. You can set it to the value of
bottom, left, middle, right, or top.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• DISABLED-When this attribute is used, the form will be displayed, but the user won't be able to
select it.
• ERROR-This proposed HTML 3 attribute takes on a string of characters as a value. This string is
displayed if the user enters an invalid value.
• HEIGHT-The height of the list of entries is controlled with this attribute. You can specify the
size in either pixels or as a percentage of the window height.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used in conjunction with the SRC attribute, to specify a message digest or checksum. This is
used when you want to be sure that a linked object is the one the Web author specified.
• MULTIPLE-When this attribute is used, multiple selections may be made.
• NAME-The string in this attribute is the name for the selection form.
• SIZE-This attribute specifies how many options are visible.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
255
Shree M .& N. Virani Science College
• SRC-When this attribute is defined, it points to an URL for an image. That image will be
displayed instead of the text defined by the <OPTION> elements.
• UNITS-This attribute enables the HEIGHT and WIDTH attributes to use units other than screen
pixels.
• WIDTH-This indicates the width of the selection window. The value must be specified as a
number of pixels.
<SELECT NAME="list1"></SELECT>
<SMALL>: Small
This proposed HTML 3 and Netscape element will cause the enclosed text to be displayed in a smaller
font. This tag has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This internationalization proposed element is used to set language characteristics. Whatever text is
enclosed within the markers for this element, will have the specified language characteristics. It has the
following attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This element is intended to display the enclosed text with a stronger emphasis than when the <EM> tag
is used. This tag has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<SUB>: Subscript
This Netscape proposed extension will force the browser to display the enclosed text as subscripts. It
has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
<SUP>: Superscript
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This proposed HTML 3 element will force the enclosed text to be aligned by defined horizontal
positions. This tag has the following attributes:
• ALIGN-This attribute specifies the alignment of the entries. You can set it to the value of
center, decimal, left, or right.
• ID-You can define tab positions with this attribute.
• INDENT-This attribute will indicate where the indents will be.
• TO-This attribute will help you line up the text.
<TABLE>: Table
This element is used to define a series of rows as table cells. Table elements are defined by <TR>
elements. This element has the following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
bleedleft, bleedright, center, left, right, or justify.
• BORDER-This attribute indicates the thickness of the border around the table.
• CELLPADDING-This attribute specifies the spacing inside the cells.
• CELLSPACING-This attribute determines the spacing between the cells.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
This proposed HTML element is used to enclose a series of table rows. This tag is not widely
supported. There are a number of attributes available for this element:
• ALIGN-This attribute indicates the alignment of text within the column. It can have the value of
char, center, left, right, or justify.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This element is used to define a particular cell in a table. This tag has the following attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, center, left, right, or justify.
• AXES-This attribute is a list of names to be displayed for the axes. The names are separated by a
comma.
• AXIS-This attribute is used to define the name for a particular axis of a cell.
• BGCOLOR-This Microsoft proposed extension enables you to specify the background color for
the particular cell. This color is represented by three pairs of hexadecimal numbers. The pairs
represent the red, green, and blue color values.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• COLSPAN-This value indicates how many columns this table cell occupies. A value of 0
indicates that the cell will span all columns.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• NOWRAP-This attribute will prevent word wrapping from occurring in the table cell.
• ROWSPAN-This value indicates how many rows this table cell occupies. A value of 0 indicates
that the cell will span all rows.
• VALIGN-This attribute indicates the vertical alignment of the table cells. You can set this
attribute to baseline, bottom, middle, or top.
• WIDTH-This proposed Netscape extension enables you to specify the width of the table cell in
pixels.
This element is used to create a form input that takes up multiple lines. This HTML tag has the
following attributes:
• ALIGN-This proposed HTML 3 attribute determines where the caption is placed. Acceptable
values are top, bottom, left, middle, and right.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• COLS-This attribute defines the total number of columns in the form. This is used to help the
browser determine how the table should be shown.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• DISABLED-This proposed HTML attribute shows the contents of the tag, but prevents its
modification.
• ERROR-This proposed HTML 3 attribute is used when an incorrect value is entered. The text
specified in this attribute is displayed on invalid input.
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• NAME-The string in this attribute is the name for the input form.
• ROWS-This attribute defines the total number of columns in the form. This is used to help the
browser determine how the table should be shown.
• WRAP-This proposed Netscape extension provides for control of the text inside this element.
You can use the values of off, physical, and virtual.
This proposed HTML 3 element will enable you to specify the attributes for a group of table rows.
Depending on the browser, these attributes will be applied across multiple browser pages, as table
footers. That is, separate HTML documents will not be affected by the TFOOT element; rather, the
way it is displayed is affected. The browser will display the table as it breaks across browser page
boundaries. The table rows to be defined are enclosed within the start and end markers for the tag. This
element has the following attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, center, left, right, or justify.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
261
Shree M .& N. Virani Science College
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• VALIGN-This indicates the vertical alignment of the text of the table cell. Acceptable values for
this attribute are baseline, bottom, middle, and top.
The text enclosed within this HTML tag, becomes a table header. This element has the following
attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, center, decimal, left, right, or justify.
• AXES-This attribute is a list of names to be displayed for the axes. The names are separated by a
comma.
• AXIS-This attribute is used to define the name for a particular axis of a cell.
• BGCOLOR-This Microsoft proposed extension enables you to specify the background color for
the particular cell. This color is represented by three pairs of hexadecimal numbers. The pairs
represent the red, green, and blue color values.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• COLSPAN-This value indicates how many columns this table cell occupies. A value of 0
indicates that the cell will span all columns.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
262
Shree M .& N. Virani Science College
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• NOWRAP-This attribute will prevent word wrapping from occurring in the table cell.
• ROWSPAN-This value indicates how many rows this table cell occupies. A value of 0 indicates
that the cell will span all rows.
• VALIGN-This attribute indicates the vertical alignment of the table cells. You can set this
attribute to baseline, bottom, middle, or top.
• WIDTH-This proposed Netscape extension enables you to specify the width of the table cell in
pixels.
This proposed HTML 3 element enables you to specify the attributes for a group of table rows.
Depending on the browser, these attributes will be applied across multiple browser pages, as table
headers. That is, separate HTML documents will not be affected by the TFOOT element; rather, the
way it is displayed is affected. The browser will display the table as its breaks across browser page
boundaries. The table rows to be defined are enclosed within the start and end markers for the tag. This
element has the following attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, center, left, right, or justify.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• VALIGN-This indicates the vertical alignment of the text of the table cell. Acceptable values for
this attribute are baseline, bottom, middle, and top.
<TITLE>: Title
This HTML element defines the enclosed text as the title for the current Web page.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This HTML tag defines a table row for a <TBODY>, <TFOOT>, or <THEAD>. This element has the
following attributes:
• ALIGN-This attribute indicates the alignment of the text within the column. It can have the value
of char, decimal, center, left, right, or justify.
• CHAR-This is used to indicate which character to align the column with. This is only interpreted
when the ALIGN attribute has been set to char.
• CHAROFF-This number is used to indicate the offset of the alignment character from the table
cell.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• VALIGN-This indicates the vertical alignment of the text of the table cell. Acceptable values for
this attribute are baseline, bottom, middle, and top.
<TR><TD>Table Data</TD>
<TT>: Teletype
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
264
Shree M .& N. Virani Science College
This HTML element displays all of the enclosed text as a teletype. Typically, the width of each of the
characters will be exactly the same. You can set the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This element shows enclosed <LI> elements as a bulleted (unordered) list. This HTML tag has the
following attributes:
• ALIGN-This attribute indicates the alignment of the text on the line. It can have the value of
center, left, right, or justify.
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• CLEAR-This is a proposed attribute to HTML 3. It can have the value of left, right, or all.
These values indicate which margin is to be clear of images so that text can appear on it.
• COMPACT-This attribute tells the browser to display the list in a compact manner. It is not,
however, supported by many browsers.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
• MD-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This attribute is
used to specify a message digest or checksum. This is used when you want to be sure that a
linked object is the one the Web author specified.
• TYPE-This Netscape proposed HTML attribute enables you to specify the type of bullets to be
used. You can use the value of circle, disc, or square.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
265
Shree M .& N. Virani Science College
• WRAP-If this proposed HTML 3 attribute is present, the browser will word wrap the enclosed
text.
<VAR>: Variable
This HTML element displays the enclosed text as a variable. This tag has the following attributes:
• CLASS-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This is a list of
calls and subclasses separated by spaces. Acceptable values that you can use have not been
defined by HTML 3.
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• ID-This is a proposed attribute to HTML 3 as part of a style sheet proposal. This defines the
current line as a destination point. These points are used for internal jumps or jumps to a
specific line.
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
This Netscape proposed extension forces a word break to occur. This is mainly used if you want to
force a word break in the middle of a non-breaking HTML element. It has no attributes.
This HTML element displays the enclosed text as is. No text formatting by the browser will be done to
the enclosed text. This tag has the following attributes:
• DIR-This is a proposed attribute to HTML for internationalization. It's used to indicate which
direction to display the text. It can either have the value ltr (left to right) or rtl (right to left).
• LANG-This is a proposed attribute to HTML for internationalization. This attribute is composed
from the two-letter language code from ISO 639. You can optionally add a period, followed by
a two-letter country code from ISO 3166. This attribute can be used by parsers to select
language-specific choices for quotation marks, ligatures, and hyphenation rules.
“Yogidham”, Kalawad Road, Rajkot – 5 Ph : 2576681 Page
266
Shree M .& N. Virani Science College
• WIDTH-This proposed Netscape extension enables you to specify the width of the multiple
lines..
<XMP>
This text will appear as you see it.
There are no special HTML elements to create
the line breaks you see.
</XMP>
Special Characters
HTML allows for the insertion of any character defined in the ISO 8859-1 character set, into Web
pages. These characters may not always be visible to all browsers, but they are defined as available
entities. Table A lists all the special characters with their corresponding HTML code. If you want to
put a particular character in your Web page, simply type in the entire string under the "HTML Code"
heading. Some of the characters have two possible HTML codes, so simply use one of them. Be sure to
include the ampersand (&) before the code, and the semicolon (;) after the code.
or &brkbar;
Section sign § §
Umlaut (dieresis) ¨ or ¨ ¨
Copyright © ©
Feminine ordinal ª ª
Left angle quote « «
(guillemotleft)
Not sign ¬ ¬
Soft hyphen ­ -