HTML Noter
HTML Noter
Introduction to HTML:
Hypertext Markup Language (HTML) is a system of code that you use to create interactive,
online pages. You’re probably familiar with the most common HTML application like www
pages.
Definition:
Hypertext Markup Language is a system of codes that identify parts and characteristics of
documents. HTML documents are plain text files that contain no images, no sounds, no
videos, and no animations; however they can include “pointers” or link to these file types,
which is how Web Pages end up looking as if they contain non-text elements. Or an
equivalent definition can be given as:
HTML documents are plain-text (also known as ASCII) files that can be created using any text
editor. You can also use word-processing software if you remember to save your document
as “text only with line breaks”
As you can see, HTML documents look nothing like the Web Pages you have likely seen
before.
<HTML>
<HEAD>
<BODY>
….
</BODY>
</HTML>
HTML is made up of tags and attributes that work together to identify document parts and
tell browsers how to display them.
Remember:
1) All tags are composed of elements that are contained within angle brackets (< >). The
angle brackets simply tell browser that the text between them is an html commands.
Some sample tags look like these:
Attributes:
Some tags work in conjuction with attributes, which provide additional command or
information about an element, such as how element should align? What other files should be
accessed? Or even the color of an element.
e.g.
<H1 align = “center”> a centered heading goes here</H1>
NOTE: When in doubt, use quotes with attributes, although they aren’t always necessary,
they never hurt.
We can use multiple attributes in a tag by using one space between each attribute, like this:
<H1 align= “center” size = “+2” color = “#ffoooo”> a widely formatted heading goes
here</H1>
A) HTML Editor:
Many WYSIWYG (What you see is what you get) editors are also available (e.g. Dream
weaver, FrontPage, Claris Home Page or Adobe Page Mill, both for Windows and Macintosh).
You may wish to try one of them after you learn some of the basics of HTML tagging.
WYSIWYG editors let you design your HTML document visually, as if you were using a word
processor, instead of writing the markup tags in a plain-text file and imagining what the
results would be. But it is always useful to know basic HTML tags to code a document even if
you are using a WYSIWYG editor, in case you want to add HTML features that your editor
doesn’t support.
B) Web Browser:
HTML documents are interpreted and displayed by web browsers. Various web browsers are
Netscape Navigator and Microsoft Internet Explorer. These are also referred as “The Big Two
Most of the browsers in use are graphical browsers: they can display elements other than
text. A text-only browser can display only text.
C) Other Resources:
The World Wide Web Consortium site, as well as several products specific Web Sites will help
you learn, use and keep up with changes in HTML.
NOTE: Most browsers, including Netscape Navigator and Microsoft Internet Explorer,
correctly display documents that do not include structure tags. However, there is no
guarantee that future versions will continue to do so or that your results will be consistent.
All HTML documents should include five structure tags that work “behind the scenes” and
essentially tell the browser which elements is include and how to display them.
A) <!DOCTYPE HTML PUBLIC “-//W3C//DTDHTML 4.0 TRANSITIONAL//EN”>
B) <HTML>
C) <HEAD>
D) <TITLE>COMPUTER POINT NEPAL</TITLE>
</HEAD>
E) <BODY>BODY OF THE HTML DOCUMENT.
</BODY>
</HTML>
a) Strict:
<!DOCTYPE HTMLPUBLIC “-//W3C//DTDHTML 4.0//EN”>
The strict version prohibits everything except “pure” HTML, and you’re unlikely to use it
unless you’re writing HTML documents that use no formatting tag and are relying on Style
Sheets to make them look good. To indicate that your document complies with the strict
specification, use:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”>
b) Transitional (loose):
<!DOCTYPE HTML PUBLIC “-//W3C//DTDHTML 4.0 TRANSITIONAL//EN”>
The transitional version is the most flexible for accommodating deprecated but still useful
tags the attributes, including all formatting tags. To indicate that your document complies
with the transitional specification, use:
<!DOCTYPE HTML PUBLIC “-//W3C//DTDHTML 4.0 Transitional//EN”>
c) Frameset:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Frameset//EN”>
The frameset specification is similar to the transitional specification, but also supports the
tags needed to use frames. To indicate that your document compiles with the frames
specification, use:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Frameset//EN”>
C) The <HEAD>tag:
The head element identifies the first part of your HTML-coded document that contains
the title. The title is shown as part of your browser’s window.
This tag contains information about the document, including its title, scripts used, style
definitions, and document descriptions. Place it in html editor as:
<!DOCTYPE..>
<HTML>
…
…
</HEAD>
</HTML>
The <TITLE> tag, required only for html 3.2 and 4 specifications, contains the document
title. The title does not appear within the browser window, although it is usually visible in
the browser’s title bar. Between the opening and the closing tags, include a title that
briefly summarizes your document’s content. To use the <TITLE> tag, enter it between
the opening and closing <HEAD> tags, like this:
The title element contains your document title and identifies its content in a global
context. The title is typically displayed in the title bar at the top of the browser window,
but not inside the window itself. The title is also what is displayed on someone’s holiest
or bookmark lists so choose something descriptive, unique, and relatively short. A title is
also used identify your page for search engines.
<TITLE> Enter title </TITLE> this is the tag used to enter the titles in the pages.
Title should represent the document, ever if the document is taken out of context. Some
good titles include the following:
Less useful titles, particularly taken out of context, include the following:
Examples
Chapter 2
Continued
The <BODY> tag encloses all the tags, attributes, and informatin that we want a visitor’s
browser to display. Almost everything in this note takes place between the <BODY>
tags. To use the <BODY> tag, enter it below the closing </HEAD> tag and above the
closing </HTML> tag, like this:
Remember: The HTML 4 specification does not require all structure tags. In fact, only two:
the <!DOCTYPE…> tag and the <TITLE> tag. If you choose to use only two tags, the code
would look like this;
<!DCOTYPE HTML PUBLIC “-//W3C//DTDHTML 4.0 Transitional//EN”>
Creating Paragraphs
One of the most common tags you’ll use is the paragraph tag, <P>, which is appropriate for
regular body text. The paragraph tag absolutely does not have to be paired-you can simply
use the opening tag, <P>, where you want to start a paragraph. As with many tags,
however, it’s easier to identify where the tag begins and ends if you use both opening and
closing tags.
To use the paragraph tags, enter them around the text you want to format as a paragraph
like this:
<P>
A whole paragraph goes right here.
</P>
You can also apply other paragraph formats instead of the <P> tag to achieve some slightly
different formats. Alignment attributes are often used with these paragraph formatting tags,
including ALIGN = LEFT, ALIGN = CENTER, ALIGN = RIGHT. To apply these attributes, include
them in any of the opening paragraph tags, like this:
<P ALIGN = CENTER>
Paragraph of information goes here.
</P>
Other paragraph formatting tags:
Paragraph Format Effect
<ADDRESS> Used for address and contact information. Often appears
in Italics.
<BLOCKQUOTE> Used for formatting a autation. Usually appears indented
from both sides and with less space between lines than
does a regular paragraph.
<PRE> Effective for formatting program code or similar
information. Usually appears in a fixed-width font with
ample space between words and lines.
Unlike documents in most word processors, carriage returns in HTML files aren’t significant.
In fact, any amount of white space – including spaces, linefeeds, and document is displayed
in a browser. So you don’t have to worry about how long your lines of text are. Word
wrapping can occur at any Point in your source file with affecting how the page will be
displayed.
In the bare-bones example shown in the Minimal HTML Document section, the first
paragraph is coded as
<P>
Welcome to the world of HTML
This is the first paragraph.
While short, it is still a paragraph!
</P>
In the source file there is a line break between the sentences. A Web browser ignores this
line break and starts a new paragraph only when it encounters another <P> tag.
Important
You must indicate paragraphs with <P> elements. A browser ignores any indications or
blank lines in the source text. Without <P> elements, the document becomes one large
paragraph. (One exception is text tagged as “preformatted,” which is explained below.) For
example, the following would produce identical output as the first bare-bones HTML
example:
<H1> Level-one heading </H1>
<P>
Welcome to the world of HTML. This is the
First Paragraph. While short it is still a Paragraph!
</P>
<P>
And this is the second paragraph.
</P>
To preserve readability in HTML files, put headings on separate lines, use a blank line or two
where it helps identify the start of a new section, and separate paragraphs with blank lines
(in addition to the <P> tags). These extra spaces will help you when you edit your files (but
your browser will ignore the extra spaces because it has its own set of rules on spacing that
do not depend on the spaces you put in your source file).
Applying Bold Italic and Other Emphases:
In additional to creating paragraphs, headings, and lists, you can also apply formatting to
individual letters and word. For example, you can make a word appear italic, bold,
underlined or superscript as in e 2. You see these character-level formatting tags only within
paragraph-level tags-that is, you can’t put a <P> tag within a character level tag such as
<B>. You have to close the character-level formatting before you close the paragraph-level
formatting.
Correct:
<P><B> this is the end of a paragraph that also uses boldface.</B></P>
<P> this is the beginning of the following paragraph.
Incorrect:
This text <B> is boldface. </P>
<P> as is this </B></P>
Although many character-formatting tags are available, you’ll probably use
<B> for boldface and <I> for italics most often.
By default, horizontal rules appear shaded; span the width of the browser window, and are a
few pixels high. You can change rule’s shading, width, height and alignment by including the
appropriate attributes.
Remember:
Pixels are the little dots on your screen that, taken together, produce an image. Pixel is
actually an abbreviation for picture element. If your display is set to 800×600, you have 800
pixels horizontally and 600 pixels vertically.
Adding Colors:
One of the easiest ways to jazz up your documents is to add colors to the background or
text. You can enliven another wise dull Web page with a splash of color or an entire color
scheme. For example, add a background color and change the text colors to coordinate with
the background. Or highlight a word or two with color and make the words leap off the page.
Or, if you’re developing a corporate site, adhere to the company’s color scheme to ensure a
consistent look.
As you’ll see in the next section; pay careful attention to how text contrasts with the
background color. If you specify a dark background color, use a light text color. Likewise, if
you specify a light background color, use a dark text color. Contrast is key for ensuing that
visitors can read information on you pages.
To specify a background color for your documents, include the BGCOLOR= “#…” attribute in
the <BODY> tag, like this:
<BODY BGCOLOR = “#FFFFFF”>
Changing body text is sometimes essential-for example, if you’re added a background color
or an image. If you’ve added a dark background color, the default black body text color
won’t adequately contrast with the background, making the text difficult or impossible to
read. In this case, you’d want to change the text color to one that’s lighter so that it
contrasts with the background sufficiently.
Changing link colors helps keep your color scheme intact-for unvisited as well as visited
links. Set the visited and unvisited links to different colors to help visitors know which links
they’ve followed and which ones they haven’t.
To change body text and link colors, simply add the attributes listed below to the opening
<BODY> tag.
Attribute Description
TEXT = “….” Sets the color for all text within the document with a color name
or a #RGGBB value.
ALINK = “….” Sets the color for active links, which are the links at the time the
visitor clicks on them, with a color name or #RRGGBB value
VLINK “…” Sets the color for links the visitor has recently followed with a
color name or a #RRGGBB value (how recently depends on
browser settings)
LINK “…..” Sets the color for unvisited links with a color name a #RRGGBB
value.
Remember
We recommend setting all web page color at one time-that way you can see how
background, text, and link colors appear as a unit.
When setting text colors, using a “safe” color is less important for text than for background.
Dithering is less apparent in small areas, such as text.
<BASEFONT> Sets text characteristics for the documentAs you’re determining which
font face to use, keep in mind that the font is available in your visitor’s
computers for them to view the fonts you specify. For example, if you
specify Technical as the font to use and your visitors do not have
Technical, their computers will substitute a font, which might not be a
font you’d consider acceptable. As a partial way of overcoming this
problem, you can list multiple faces in order of preference; the machine
displays the first available. For example, a list of “Comic Sans Ms,
Tekton, Times, Arial” will display Comic Sans MS if available, then try
Technical, Then Tekton, and so forth.
To specify font characteristics, follow these steps. You can set some or all of the
characteristics used in this example.
1. Identify the text to format with the <FONT> tag.
<FONT> look at this!</FONT>
2. Select a specific font using the FACE = attribute.
<FONT FACE = “Verdana, Times New Roman, Times”>look at this!</FONT>
3. Change the font size using the Size = attribute. You set the size of text on a
relative scale from 1 to 7, with the default size being 3. Either set the size
absolutely, with a number from 1 to 7, or relatively + or – to change the size.
Almost newer browsers (and all HTML 3.2 and 4-complaint browsers) support SIZE
= to set font size. The only significant downside to setting the font size is that
you’ve your visitor might already have increased (or decreased) the default font
size, so your size change might have more of an effect than you expected.
<FONT FACE = “Verdana, Times New Roman, Times” SIZE = “+2” look at this!
</FONT>
4. Add a COLOR = attribute to set the colors, using a color name or a #RRGGBB
value.
<FONT FACE = “Verdana, Times New Roman, Times” SIZE = “+2” COLOR =
#FF0000”> look at this!</FONT>
Creating Headings:
Heading break up large areas of text, announce topics to follow, and arrange information
according to a logical hierarchy. HTML provides six different levels of headings; <H1> is the
largest of the headings, and <H6> is the smallest.
HTML has six levels of headings, numbered 1 through 6, with 1 being the largest. Headings
are typically displayed in larger and/or bolder fonts than normal body text. The first heading
in each document should be tagged <H1>.
Do not skip levels of headings in your document. For example, don’t start with a level-one
heading <H1> and then next use a level-three <H3> heading.
Remember:
For most documents, limit yourself to two or three levels. After three heading levels, many
visitors begin to lose track of your hierarchy. If you find that using several heading levels,
consider reorganizing your document too many heading levels often indicates a larger
organizational problem.
To use heading tags, enter them around the heading text, like this:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<TITLE>
Title that summarizes the document’s content
</TITLE>
</HEAD>
<BODY> all the tags, attributes and information in the document body go here
<H1> first level heading </H1>
<H2> second level heading </H2>
<H3> Third level heading </H3>
</BODY>
</HTML>
In general, you should use heading tags only for document headings- that is, don’t use
heading tags for figure captions or to emphasize information within text. There are six
different types of heading in ascending order. They are follows:
1. H1
2. H2
3. H3
4. H4
5. H5
6. H6
By Default, all browsers align headings on the left. Most browsers, however support
alignment attributes, which also let you right-align and center headings.
Remember:
If you’re writing for a wide audience, some of whom might be using older browsers, surround
the ALIGN = CENTER attribute with <CENTER> tags to ensure that the text actually appears
centered, yielding something like this: <CENTER><H1 ALIGN = CENTER> Centered
heading</H1></CENTER>
Creating Lists:
Lists are a great way to provide information in a structured, easy-to-read format. They help
your visitor easily spot information, and they draw attention to important information. A list
is a good form for a procedure. HTML supports unnumbered, numbered and definition lists.
You can nest lists too, but use this feature sparingly because too many nested items can get
difficult to follow.
HTML supports unnumbered, numbered, and definition lists. You can nest lists too, but this
feature sparingly because too many nested items can get difficult to follow.
Unordered Lists
The following steps show you how to create a bulleted list (unordered list)
Start with text you want to format as a list.
Lions
Tigers
Bears
Oh, My!
1. Insert the <UL> tags around the list text.
<UL>
Lions
Tigers
Bears
Oh, My!
</UL>
2. Type the <LI> tags for each list item
<UL>
<LI> Lions
<LI> Tigers
<LI>Bears
<LI> Oh, My!
</UL>
To change your list from unordered bulleted to ordered numbered, change the <UL> to
<OL> and </UL> to </OL>.
Note: Type attributes for unordered lists are currently supported by many (but by no means
all) browsers, although, support is expected to continue to grow.
First, you can start a numbered list with a value other than 1 (or A, a, I or i). Simply include
the START = attribute in the initial <OL> tag, as (OL START = 51>. Or, you can even change
specific number within a list by the VALUE = attribute in the <LI> tag, as in <LI VALUE =7>.
To use this attributes, include them in the <OL> tag, like this:
<OL START = 51>
<LI>this is the fifty-first item.
<LI>this is the fifty-second.
<LI TYPE = I VALUE = 7> this item was renumbered to be the seventh, using
lower case roman numerals, just because we can.
</OL>
Second, you can use nested ordered list and different TYPE = attribute to create outlines.
The numbering continues past each lower level case section without the need to manually
renumber with a VALUE = attribute.
<OL TYPE = I>
<LI>top level item
<LI> another top level item
<OL TYPE = A>
<LI>second level item
<LI>another second level item
<OL TYPE = 1>
<LI> third level item
<LI> another third level item
</OL>
<LI>another second level item
</OL>
<LI>a top level item
</OL>
Nested Lists
List can be nested. You can also have a number of paragraphs, each containing a nested list,
in single list item.
Here is a sample-nested list:
<UL>
<LI> List of computer devices
<UL>
<LI> Keyboard
<LI> mouse
<LI>monitor
</UL>
<LI>processors
<UL>
<LI>pentium
<LI>AMD
</UL>
</UL>
The nested list is displayed as:
List of computer devices
Keyboard
Mouse
Monitor
Processors
Pentium
AMD
Definition List:
Finally, one special list variant, definition list, can be useful for providing two levels of
information. You can think of definition lists as dictionary entries-you have two levels of
information: the entry, followed by a definition. You can use this list to provide glossary-type
information, or you can use the to provide two-level lists.
A definition list (coded as <DL>) usually consists of alternating a definition term (coded as
<DT>) and a definition (coded as <DD>). Web browsers generally format the definition on a
new line and indent it.
Tables
Introduction to tables
The HTML table model allows you to arrange data -- text, preformatted text, images, links,
forms, form fields, other tables, etc. -- into rows and columns of cells.
Each table may have an associated caption (see the CAPTION element) that provides a short
description of the table's purpose.
Table rows may be grouped into a head, foot, and body sections, (via the THEAD, TFOOT and
TBODY elements, respectively). Row groups convey additional structural information and
may be rendered by browsers in ways that emphasize this structure. Browsers may exploit
the head/body/foot division to support scrolling of body sections independently of the head
and foot sections. When long tables are printed, the head and foot information may be
repeated on each page that contains table data.
You may also group columns to provide additional structural information that may be
exploited by browsers. Furthermore, you may declare column properties at the start of a
table definition (via the COLGROUP and COL elements) in a way that enables browsers to
render the table incrementally rather than having to wait for all the table data to arrive
before rendering.
Table cells may either contain "header" information (see the TH element) or "data" (see the
TD element). Cells may span multiple rows and columns.
Tables should not be used purely as a means to layout document content as this may
present problems when rendering to non-visual media. Additionally, when used with
graphics, these tables may force users to scroll horizontally to view a table designed on a
system with a larger display. To minimize these problems, authors should use style sheets to
control layout rather than tables.
Here's a simple table that illustrates some of the features of the HTML table model. The
following table definition:
<TABLE border="1">
<CAPTION><EM>A test table with merged cells</EM></CAPTION>
<TR><TH rowspan="2"><TH colspan="2">Average
<TH rowspan="2">Red<BR>eyes
<TR><TH>height<TH>weight
<TR><TH>Males<TD>1.9<TD>0.003<TD>40%
<TR><TH>Females<TD>1.7<TD>0.002<TD>43%
</TABLE>
might be rendered something like this by a graphical browser:
Table directionality
The directionality of a table is either the inherited directionality (the default is left-to-right) or
that specified by the dir attribute for the TABLE element.
For a left-to-right table, column zero is on the left side and row zero is at the top. For a right-
to-left table, column zero is on the right side and row zero is at the top.
When a browser allots extra cells to a row (see the section on calculating the number of
columns in a table), extra row cells are added to the right of the table for left-to-right tables
and to the left side for right-to-left tables.
Note that TABLE is the only element on which dir reverses the visual order of the columns; a
single table row (TR) or a group of columns (COLGROUP) cannot be independently reversed.
When set for the TABLE element, the dir attribute also affects the direction of text within
table cells (since the dir attribute is inherited by block-level elements).
To specify a right-to-left table, set the dir attribute as follows:
<TABLE dir="RTL">
...the rest of the table...
</TABLE>
The direction of text in individual cells can be changed by setting the dir attribute in an
element that defines the cell. Please consult the section on bidirectional text for more
information on text direction issues.
Attribute definitions
align = top|bottom|left|right
Deprecated. For visual browsers, this attribute specifies the position of the caption
with respect to the table. Possible values:
top: The caption is at the top of the table. This is the default value.
bottom: The caption is at the bottom of the table.
left: The caption is at the left of the table.
right: The caption is at the right of the table.
When present, the CAPTION element's text should describe the nature of the table. The
CAPTION element is only permitted immediately after the TABLE start tag. A TABLE element
may only contain one CAPTION element.
Browsers allow sighted people to quickly grasp the structure of the table from the headings
as well as the caption. A consequence of this is that captions will often be inadequate as a
summary of the purpose and structure of the table from the perspective of people relying on
non-visual browsers.
Visual browsers should avoid clipping any part of the table including the caption, unless a
means is provided to access all parts, e.g., by horizontal or vertical scrolling. We recommend
that the caption text be wrapped to the same width as the table.
Row groups: the THEAD, TFOOT, and TBODY elements
THEAD and TFOOT
TBODY
Start tag: optional, End tag: optional
Table rows may be grouped into a table head, table foot, and one or more table body
sections, using the THEAD, TFOOT and TBODY elements, respectively. This division enables
browsers to support scrolling of table bodies independently of the table head and foot. When
long tables are printed, the table head and foot information may be repeated on each page
that contains table data.
The table head and table foot should contain information about the table's columns. The
table body should contain rows of table data.
When present, each THEAD, TFOOT, and TBODY contains a row group. Each row group must
contain at least one row, defined by the TR element.
This example illustrates the order and structure of table heads, feet, and bodies.
<TABLE>
<THEAD>
<TR> ...header information...
</THEAD>
<TFOOT>
<TR> ...footer information...
</TFOOT>
<TBODY>
<TR> ...first row of block one data...
<TR> ...second row of block one data...
</TBODY>
<TBODY>
<TR> ...first row of block two data...
<TR> ...second row of block two data...
<TR> ...third row of block two data...
</TBODY>
</TABLE>
TFOOT must appear before TBODY within a TABLE definition so that browsers can render the
foot before receiving all of the (potentially numerous) rows of data. The following
summarizes which tags are required and which may be omitted:
The TBODY start tag is always required except when the table contains only one table
body and no table head or foot sections. The TBODY end tag may always be safely
omitted.
The start tags for THEAD and TFOOT are required when the table head and foot
sections are present respectively, but the corresponding end tags may always be
safely omitted.
The table of the previous example could be shortened by removing certain end tags, as in:
<TABLE>
<THEAD>
<TR> ...header information...
<TFOOT>
<TR> ...footer information...
<TBODY>
<TR> ...first row of block one data...
<TR> ...second row of block one data...
<TBODY>
<TR> ...first row of block two data...
<TR> ...second row of block two data...
<TR> ...third row of block two data...
</TABLE>
The THEAD, TFOOT, and TBODY sections must contain the same number of columns.
A table may either contain a single implicit column group (no COLGROUP element delimits
the columns) or any number of explicit column groups (each delimited by an instance of the
COLGROUP element).
The COL element allows authors to share attributes among several columns without implying
any structural grouping. The "span" of the COL element is the number of columns that will
share the element's attributes.
The table in the following example contains two column groups. The first column group
contains 10 columns and the second contains 5 columns. The default width for each column
in the first column group is 50 pixels. The width of each column in the second column group
will be the minimum required for that column.
<TABLE>
<COLGROUP span="10" width="50">
<COLGROUP span="5" width="0*">
<THEAD>
<TR><TD> ...
</TABLE>
Attribute definitions
span = number
This attribute, whose value must be an integer > 0, specifies the number of columns
"spanned" by the COL element; the COL element shares its attributes with all the
columns it spans. The default value for this attribute is 1 (i.e., the COL element refers
to a single column). If the span attribute is set to N > 1, the current COL element
shares its attributes with the next N-1 columns.
width = multi-length
This attribute specifies a default width for each column spanned by the current COL
element. It has the same meaning as the width attribute for the COLGROUP element
and overrides it.
The COL element allows authors to group together attribute specifications for table columns.
The COL does not group columns together structurally -- that is the role of the COLGROUP
element. COL elements are empty and serve only as a support for attributes. They may
appear inside or outside an explicit column group (i.e., COLGROUP element).
The width attribute for COL refers to the width of each column in the element's span.
For example, for each of the following tables, the two column calculation methods should
result in three columns. The first three tables may be rendered incrementally.
<TABLE>
<COLGROUP span="3"></COLGROUP>
<TR><TD> ...
...rows...
</TABLE>
<TABLE>
<COLGROUP>
<COL>
<COL span="2">
</COLGROUP>
<TR><TD> ...
...rows...
</TABLE>
<TABLE>
<COLGROUP>
<COL>
</COLGROUP>
<COLGROUP span="2">
<TR><TD> ...
...rows...
</TABLE>
<TABLE>
<TR>
<TD><TD><TD>
</TR>
</TABLE>
If you specify no width information for a column, a browser may not be able to incrementally
format the table since it must wait for the entire column of data to arrive in order to allot an
appropriate width.
If column widths prove to be too narrow for the contents of a particular table cell, browsers
may choose to reflow the table.
The table in this example contains six columns. The first one does not belong to an explicit
column group. The next three belong to the first explicit column group and the last two
belong to the second explicit column group. This table cannot be formatted incrementally
since it contains proportional column width specifications and no value for the width
attribute for the TABLE element.
Once the (visual) browser has received the table's data: the available horizontal space will
be alloted by the browser as follows: First the browser will allot 30 pixels to columns one and
two. Then, the minimal space required for the third column will be reserved. The remaining
horizontal space will be divided into six equal portions (since 2* + 1* + 3* = 6 portions).
Column four (2*) will receive two of these portions, column five (1*) will receive one, and
column six (3*) will receive three.
<TABLE>
<COLGROUP>
<COL width="30">
<COLGROUP>
<COL width="30">
<COL width="0*">
<COL width="2*">
<COLGROUP align="center">
<COL width="1*">
<COL width="3*" align="char" char=":">
<THEAD>
<TR><TD> ...
...rows...
</TABLE>
In the following table, the column width specifications allow the browser to format the table
incrementally:
<TABLE width="200">
<COLGROUP span="10" width="15">
<COLGROUP width="*">
<COL id="penultimate-column">
<COL id="last-column">
<THEAD>
<TR><TD> ...
...rows...
</TABLE>
The first ten columns will be 15 pixels wide each. The last two columns will each receive half
of the remaining 50 pixels. Note that the COL elements appear only so that an id value may
be specified for the last two columns.
Note. Although the width attribute on the TABLE element is not deprecated, you are
encouraged to use style sheets to specify table widths.
The TR elements acts as a container for a row of table cells. The end tag may be omitted.
This sample table contains three rows, each begun by the TR element:
<TABLE summary="This table charts the number of cups
of coffee consumed by each senator, the type
of coffee (decaf or regular), and whether
taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<TR> ...A header row...
<TR> ...First row of data...
<TR> ...Second row of data...
...the rest of the table...
</TABLE>
Attribute definitions
headers = idrefs
This attribute specifies the list of header cells that provide header information for the
current data cell. The value of this attribute is a space-separated list of cell names;
those cells must be named by setting their id attribute. Authors generally use the
headers attribute to help non-visual browsers render header information about data
cells (e.g., header information is spoken prior to the cell data), but the attribute may
also be used in conjunction with style sheets. See also the scope attribute.
scope = scope-name
This attribute specifies the set of data cells for which the current header cell provides
header information. This attribute may be used in place of the headers attribute,
particularly for simple tables. When specified, this attribute must have one of the
following values:
row: The current cell provides header information for the rest of the row that
contains it (see also the section on table directionality).
col: The current cell provides header information for the rest of the column
that contains it.
rowgroup: The header cell provides header information for the rest of the
row group that contains it.
colgroup: The header cell provides header information for the rest of the
column group that contains it.
abbr = text
This attribute should be used to provide an abbreviated form of the cell's content,
and may be rendered by browsers when appropriate in place of the cell's content.
Abbreviated names should be short since browsers may render them repeatedly. For
instance, speech synthesizers may render the abbreviated headers relating to a
particular cell before rendering that cell's content.
axis = cdata
This attribute may be used to place a cell into conceptual categories that can be
considered to form axes in an n-dimensional space. Browsers may give users access
to these categories (e.g., the user may query the browser for all cells that belong to
certain categories, the browser may present a table in the form of a table of contents,
etc.). Please consult the section on categorizing cells for more information. The value
of this attribute is a comma-separated list of category names.
rowspan = number
This attribute specifies the number of rows spanned by the current cell. The default
value of this attribute is one ("1"). The value zero ("0") means that the cell spans all
rows from the current row to the last row of the table section (THEAD, TBODY, or
TFOOT) in which the cell is defined.
colspan = number
This attribute specifies the number of columns spanned by the current cell. The
default value of this attribute is one ("1"). The value zero ("0") means that the cell
spans all columns from the current column to the last column of the column group
(COLGROUP) in which the cell is defined.
Table cells may contain two types of information: header information and data. This
distinction enables browsers to render header and data cells distinctly, even in the absence
of style sheets. For example, visual browsers may present header cell text with a bold font.
Speech synthesizers may render header information with a distinct voice inflection.
The TH element defines a cell that contains header information. Browsers have two pieces of
header information available: the contents of the TH element and the value of the abbr
attribute. Browsers must render either the contents of the cell or the value of the abbr
attribute. For visual media, the latter may be appropriate when there is insufficient space to
render the full contents of the cell. For non-visual media abbr may be used as an
abbreviation for table headers when these are rendered along with the contents of the cells
to which they apply.
The headers and scope attributes also allow authors to help non-visual browsers process
header information. Please consult the section on labeling cells for non-visual browsers for
information and examples.
The TD element defines a cell that contains data.
Cells may be empty (i.e., contain no data).
For example, the following table contains four columns of data, each headed by a column
description.
<TABLE summary="This table charts the number of cups
of coffee consumed by each senator, the type
of coffee (decaf or regular), and whether
taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<TR>
<TH>Name</TH>
<TH>Cups</TH>
<TH>Type of Coffee</TH>
<TH>Sugar?</TH>
<TR>
<TD>T. Sexton</TD>
<TD>10</TD>
<TD>Espresso</TD>
<TD>No</TD>
<TR>
<TD>J. Dinnen</TD>
<TD>5</TD>
<TD>Decaf</TD>
<TD>Yes</TD>
</TABLE>
Note that if the TD defining cell "6" had been omitted, an extra empty cell would have been
added by the browser to complete the row.
Similarly, in the following table definition:
<TABLE border="1">
<TR><TD>1 <TD>2 <TD>3
<TR><TD colspan="2">4 <TD>6
<TR><TD>7 <TD>8 <TD>9
</TABLE>
cell "4" spans two columns, so the second TD in the row actually defines the third cell ("6"):
A graphical browser might render this as:
Defining overlapping cells is an error. Browsers may vary in how they handle this error (e.g.,
rendering may vary).
The following illegal example illustrates how one might create overlapping cells. In this table,
cell "5" spans two rows and cell "7" spans two columns, so there is overlap in the cell
between "7" and "9":
<TABLE border="1">
<TR><TD>1 <TD>2 <TD>3
<TR><TD>4 <TD rowspan="2">5 <TD>6
<TR><TD colspan="2">7 <TD>9
</TABLE>
Table formatting by Browsers
HTML 4 includes mechanisms to control:
border styles
horizontal and vertical alignment of cell contents
and cell margins
Borders and rules
The following attributes affect a table's external frame and internal rules.
Attribute definitions
frame = void|above|below|hsides|lhs|rhs|vsides|box|border
This attribute specifies which sides of the frame surrounding a table will be visible.
Possible values:
void: No sides. This is the default value.
above: The top side only.
below: The bottom side only.
hsides: The top and bottom sides only.
vsides: The right and left sides only.
lhs: The left-hand side only.
rhs: The right-hand side only.
box: All four sides.
border: All four sides.
rules = none|groups|rows|cols|all
This attribute specifies which rules will appear between cells within a table. The
rendering of rules is browser dependent. Possible values:
none: No rules. This is the default value.
groups: Rules will appear between row groups (see THEAD, TFOOT, and
TBODY) and column groups (see COLGROUP and COL) only.
rows: Rules will appear between rows only.
cols: Rules will appear between columns only.
all: Rules will appear between all rows and columns.
border = pixels
This attributes specifies the width (in pixels only) of the frame around a table (see the
Note below for more information about this attribute).
To help distinguish the cells of a table, we can set the border attribute of the TABLE element.
Consider a previous example:
<TABLE border="1"
summary="This table charts the number of cups
of coffee consumed by each senator, the type
of coffee (decaf or regular), and whether
taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<TR>
<TH>Name</TH>
<TH>Cups</TH>
<TH>Type of Coffee</TH>
<TH>Sugar?</TH>
<TR>
<TD>T. Sexton</TD>
<TD>10</TD>
<TD>Espresso</TD>
<TD>No</TD>
<TR>
<TD>J. Dinnen</TD>
<TD>5</TD>
<TD>Decaf</TD>
<TD>Yes</TD>
</TABLE>
In the following example, the browser should show borders five pixels thick on the left-hand
and right-hand sides of the table, with rules drawn between each column.
<TABLE border="5" frame="vsides" rules="cols">
<TR> <TD>1 <TD>2 <TD>3
<TR> <TD>4 <TD>5 <TD>6
<TR> <TD>7 <TD>8 <TD>9
</TABLE>
The following settings should be observed by browsers for backwards compatibility.
Setting border="0" implies frame="void" and, unless otherwise specified,
rules="none".
Other values of border imply frame="border" and, unless otherwise specified,
rules="all".
The value "border" in the start tag of the TABLE element should be interpreted as the
value of the frame attribute. It implies rules="all" and some default (non-zero) value
for the border attribute.
Attribute definitions
align = left|center|right|justify|char
This attribute specifies the alignment of data and the justification of text in a cell.
Possible values:
left: Left-flush data/Left-justify text. This is the default value for table data.
center: Center data/Center-justify text. This is the default value for table
headers.
right: Right-flush data/Right-justify text.
justify: Double-justify text.
char: Align text around a specific character. If a browser doesn't support
character alignment, behavior in the presence of this value is unspecified.
valign = top|middle|bottom|baseline
This attribute specifies the vertical position of data within a cell. Possible values:
top: Cell data is flush with the top of the cell.
middle: Cell data is centered vertically within the cell. This is the default value.
bottom: Cell data is flush with the bottom of the cell.
baseline: All cells in the same row as a cell whose valign attribute has this
value should have their textual data positioned so that the first text line
occurs on a baseline common to all cells in the row. This constraint does not
apply to subsequent text lines in these cells.
char = character
This attribute specifies a single character within a text fragment to act as an axis for
alignment. The default value for this attribute is the decimal point character for the
current language as set by the lang attribute (e.g., the period (".") in English and the
comma (",") in French). Browsers are not required to support this attribute.
charoff = length
When present, this attribute specifies the offset to the first occurrence of the
alignment character on each line. If a line doesn't include the alignment character, it
should be horizontally shifted to end at the alignment position.
When charoff is used to set the offset of an alignment character, the direction of
offset is determined by the current text direction (set by the dir attribute). In left-to-
right texts (the default), offset is from the left margin. In right-to-left texts, offset is
from the right margin. Browsers are not required to support this attribute.
The table in this example aligns a row of currency values along a decimal point. We set the
alignment character to "." explicitly.
<TABLE border="1">
<COLGROUP>
<COL><COL align="char" char=".">
<THEAD>
<TR><TH>Vegetable <TH>Cost per kilo
<TBODY>
<TR><TD>Lettuce <TD>$1
<TR><TD>Silver carrots <TD>$10.50
<TR><TD>Golden turnips <TD>$100.30
</TABLE>
When the contents of a cell contain more than one instance of the alignment character
specified by char and the contents wrap, browser behavior is undefined. Authors should
therefore be attentive in their use of char.
The default alignment for cells depends on the browser. However, browsers should
substitute the default attribute for the current directionality (i.e., not just "left" in all cases).
Browsers that do not support the "justify" value of the align attribute should use the value of
the inherited directionality in its place.
Cell margins
Attribute definitions
cellspacing = length
This attribute specifies how much space the browser should leave between the left
side of the table and the left-hand side of the leftmost column, the top of the table
and the top side of the topmost row, and so on for the right and bottom of the table.
The attribute also specifies the amount of space to leave between cells.
cellpadding = length
This attribute specifies the amount of space between the border of the cell and its
contents. If the value of this attribute is a pixel length, all four margins should be this
distance from the contents. If the value of the attribute is a percentage length, the
top and bottom margins should be equally separated from the content based on a
percentage of the available vertical space, and the left and right margins should be
equally separated from the content based on a percentage of the available horizontal
space.
These two attributes control spacing between and within cells. The following illustration
explains how they relate:
In the following example, the cellspacing attribute specifies that cells should be separated
from each other and from the table frame by twenty pixels. The cellpadding attribute
specifies that the top margin of the cell and the bottom margin of the cell will each be
separated from the cell's contents by 10% of the available vertical space (the total being
20%). Similarly, the left margin of the cell and the right margin of the cell will each be
separated from the cell's contents by 10% of the available horizontal space (the total being
20%).
<TABLE cellspacing="20" cellpadding="20%">
<TR> <TD>Data1 <TD>Data2 <TD>Data3
</TABLE>
If a table or given column has a fixed width, cellspacing and cellpadding may demand more
space than assigned. Browsers may give these attributes precedence over the width
attribute when a conflict occurs, but are not required to.
Note the use of the scope attribute with the "row" value. Although the first cell in each row
contains data, not header information, the scope attribute makes the data cell behave like a
row header cell. This allows speech synthesizers to provide the relevant course name upon
request or to state it immediately before each cell's content.
Sample table
This sample illustrates grouped rows and columns.
<TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
<COLGROUP align="center" span="2">
<COLGROUP align="center" span="3">
<THEAD valign="top">
<TR>
<TH>Code-Page<BR>ID
<TH>Name
<TH>ACP
<TH>OEMCP
<TH>Windows<BR>NT 3.1
<TH>Windows<BR>NT 3.51
<TH>Windows<BR>95
<TBODY>
<TR><TD>1200<TD>Unicode (BMP of ISO/IEC-10646)<TD><TD><TD>X<TD>X<TD>*
<TR><TD>1250<TD>Windows 3.1 Eastern European<TD>X<TD><TD>X<TD>X<TD>X
<TR><TD>1251<TD>Windows 3.1 Cyrillic<TD>X<TD><TD>X<TD>X<TD>X
<TR><TD>1252<TD>Windows 3.1 US (ANSI)<TD>X<TD><TD>X<TD>X<TD>X
<TR><TD>1253<TD>Windows 3.1 Greek<TD>X<TD><TD>X<TD>X<TD>X
<TR><TD>1254<TD>Windows 3.1 Turkish<TD>X<TD><TD>X<TD>X<TD>X
<TR><TD>1255<TD>Hebrew<TD>X<TD><TD><TD><TD>X
<TR><TD>1256<TD>Arabic<TD>X<TD><TD><TD><TD>X
<TR><TD>1257<TD>Baltic<TD>X<TD><TD><TD><TD>X
<TR><TD>1361<TD>Korean (Johab)<TD>X<TD><TD><TD>**<TD>X
<TBODY>
<TR><TD>437<TD>MS-DOS United States<TD><TD>X<TD>X<TD>X<TD>X
<TR><TD>708<TD>Arabic (ASMO 708)<TD><TD>X<TD><TD><TD>X
<TR><TD>709<TD>Arabic (ASMO 449+, BCON V4)<TD><TD>X<TD><TD><TD>X
<TR><TD>710<TD>Arabic (Transparent Arabic)<TD><TD>X<TD><TD><TD>X
<TR><TD>720<TD>Arabic (Transparent ASMO)<TD><TD>X<TD><TD><TD>X
</TABLE>
A graphical browser might render this as:
This example illustrates how COLGROUP can be used to group columns and set the default
column alignment. Similarly, TBODY is used to group rows. The frame and rules attributes
tell the browser which borders and rules to render.
Links
A link has two ends -- called anchors -- and a direction. The link starts at the "source" anchor
and points to the "destination" anchor, which may be any Web resource (e.g., an image, a
video clip, a sound bite, a program, an HTML document, an element within an HTML
document, etc.).
The following HTML excerpt contains two links, one whose destination anchor is an HTML
document named "chapter2.html" and the other whose destination anchor is a GIF image in
the file "forest.gif":
<BODY>
...some text...
<P>You'll find a lot more in <A href="chapter2.html">chapter two</A>.
See also this <A href="../images/forest.gif">map of the enchanted forest.</A>
</BODY>
By activating these links (by clicking with the mouse, through keyboard input, voice
commands, etc.), users may visit these resources. Note that the href attribute in each source
anchor specifies the address of the destination anchor with a URI.
The destination anchor of a link may be an element within an HTML document. The
destination anchor must be given an anchor name and any URI addressing this anchor must
include the name as its fragment identifier.
Destination anchors in HTML documents may be specified either by the A element (naming it
with the name attribute), or by any other element (naming with the id attribute).
Thus, for example, an author might create a table of contents whose entries link to header
elements H2, H3, etc., in the same document. Using the A element to create destination
anchors, we would write:
<H1>Table of Contents</H1>
<P><A href="#section1">Introduction</A><BR>
<A href="#section2">Some background</A><BR>
<A href="#section2.1">On a more personal note</A><BR>
...the rest of the table of contents...
...the document body...
<H2><A name="section1">Introduction</A></H2>
...section 1...
<H2><A name="section2">Some background</A></H2>
...section 2...
<H3><A name="section2.1">On a more personal note</A></H3>
...section 2.1...
We may achieve the same effect by making the header elements themselves the anchors:
<H1>Table of Contents</H1>
<P><A href="#section1">Introduction</A><BR>
<A href="#section2">Some background</A><BR>
<A href="#section2.1">On a more personal note</A><BR>
...the rest of the table of contents...
...the document body...
<H2 id="section1">Introduction</H2>
...section 1...
<H2 id="section2">Some background</H2>
...section 2...
<H3 id="section2.1">On a more personal note</H3>
...section 2.1...
The A element
Start tag: required, End tag: required
Attribute definitions
name = cdata
This attribute names the current anchor so that it may be the destination of another
link. The value of this attribute must be a unique anchor name. The scope of this
name is the current document. Note that this attribute shares the same name space
as the id attribute.
href = uri
This attribute specifies the location of a Web resource, thus defining a link between
the current element (the source anchor) and the destination anchor defined by this
attribute.
type = content-type
This attribute gives an advisory hint as to the content type of the content available at
the link target address. It allows browsers to opt to use a fallback mechanism rather
than fetch the content if they are advised that they will get content in a content type
they do not support.
Authors who use this attribute take responsibility to manage the risk that it may
become inconsistent with the content available at the link target address.
rel = link-types
This attribute describes the relationship from the current document to the anchor
specified by the href attribute. The value of this attribute is a space-separated list of
link types.
rev = link-types
This attribute is used to describe a reverse link from the anchor specified by the href
attribute to the current document. The value of this attribute is a space-separated list
of link types.
In the example that follows, the A element defines a link. The source anchor is the text "W3C
Web site" and the destination anchor is "http://www.w3.org/":
For more information about W3C, please consult the
<A href="http://www.w3.org/">W3C Web site</A>.
This link designates the home page of the World Wide Web Consortium. When a user
activates this link in a browser, the browser will retrieve the resource, in this case, an HTML
document.
Browsers generally render links in such a way as to make them obvious to users
(underlining, reverse video, etc.). The exact rendering depends on the browser. Rendering
may vary according to whether the user has already visited the link or not. A possible visual
rendering of the previous link might be:
For more information about W3C, please consult the W3C Web site.
This creates an anchor around the text "This is the location of anchor one.". Usually, the
contents of A are not rendered in any special way when A defines an anchor only.
Having defined the anchor, we may link to it from the same or another document. URIs that
designate anchors contain a "#" character followed by the anchor name (the fragment
identifier). Here are some examples of such URIs:
An absolute URI: http://www.mycompany.com/one.html#anchor-one
A relative URI: ./one.html#anchor-one or one.html#anchor-one
When the link is defined in the same document: #anchor-one
Thus, a link defined in the file "two.html" in the same directory as "one.html" would refer to
the anchor as follows:
...text before the link...
For more information, please consult <A href="./one.html#anchor-one"> anchor
one</A>.
...text after the link...
The A element in the following example specifies a link (with href) and creates a named
anchor (with name) simultaneously:
I just returned from vacation! Here's a
<A name="anchor-two"
href="http://www.somecompany.com/People/Ian/vacation/family.png">
photo of my family at the lake.</A>.
This example contains a link to a different type of Web resource (a PNG image). Activating
the link should cause the image resource to be retrieved from the Web (and possibly
displayed if the system has been configured to do so).
Previous versions of HTML allowed authors to include images (via IMG) and applets (via
APPLET). These elements have several limitations:
They fail to solve the more general problem of how to include new and future media
types.
The APPLET element only works with Java-based applets. This element is deprecated
in favor of OBJECT.
They pose accessibility problems.
To address these issues, HTML 4 introduces the OBJECT element, which offers an all-purpose
solution to generic object inclusion. The OBJECT element allows HTML authors to specify
everything required by an object for its presentation by a browser: source code, initial
values, and run-time data. In this specification, the term "object" is used to describe the
things that people want to place in HTML documents; other commonly used terms for these
things are: applets, plug-ins, media handlers, etc.
The new OBJECT element thus subsumes some of the tasks carried out by existing elements.
Consider the following chart of functionalities:
Type of inclusion Specific element Generic
element
Image IMG OBJECT
Applet APPLET (Deprecated.) OBJECT
Another HTML IFRAME OBJECT
document
The chart indicates that each type of inclusion has a specific and a general solution. The
generic OBJECT element will serve as the solution for implementing future media types.
To include images, authors may use the OBJECT element or the IMG element.
To include applets, authors should use the OBJECT element as the APPLET element is
deprecated.
To include one HTML document in another, authors may use either the new IFRAME element
or the OBJECT element. In both cases, the embedded document remains independent of the
main document. Visual browsers may present the embedded document in a distinct window
within the main document. Please consult the notes on embedded documents for a
comparison of OBJECT and IFRAME for document inclusion.
Images and other included objects may have hyperlinks associated with them, both through
the standard linking mechanisms, but also via image maps. An image map specifies active
geometric regions of an included object and assigns a link to each region. When activated,
these links may cause a document to be retrieved, may run a program on the server, etc.
In the following sections, we discuss the various mechanisms available to authors for
multimedia inclusions and creating image maps for those inclusions.
Attribute definitions
src = uri
This attribute specifies the location of the image resource. Examples of widely
recognized image formats include GIF, JPEG, and PNG.
longdesc = uri
This attribute specifies a link to a long description of the image. This description
should supplement the short description provided using the alt attribute. When the
image has an associated image map, this attribute should provide information about
the image map's contents.
name = cdata
This attribute names the element so that it may be referred to from style sheets or
scripts. Note. This attribute has been included for backwards compatibility.
Applications should use the id attribute to identify elements.
The IMG element embeds an image in the current document at the location of the element's
definition. The IMG element has no content; it is usually replaced inline by the image
designated by the src attribute, the exception being for left or right-aligned images that are
"floated" out of line.
In an earlier example, we defined a link to a family photo. Here, we insert the photo directly
into the current document:
<BODY>
<P>I just returned from vacation! Here's a photo of my family at the lake:
<IMG src="http://www.somecompany.com/People/Ian/vacation/family.png"
alt="A photo of my family at the lake.">
</BODY>
This inclusion may also be achieved with the OBJECT element as follows:
<BODY>
<P>I just returned from vacation! Here's a photo of my family at the lake:
<OBJECT data="http://www.somecompany.com/People/Ian/vacation/family.png"
type="image/png">
A photo of my family at the lake.
</OBJECT>
</BODY>
The alt attribute specifies alternate text that is rendered when the image cannot be
displayed (see below for information on how to specify alternate text ). Browsers must
render alternate text when they cannot support images, they cannot support a certain image
type or when they are configured not to display images.
The following example shows how the longdesc attribute can be used to link to a richer
description:
<BODY>
<P>
<IMG src="sitemap.gif"
alt="HP Labs Site Map"
longdesc="sitemap.html">
</BODY>
The alt attribute provides a short description of the image. This should be sufficient to allow
users to decide whether they want to follow the link given by the longdesc attribute to the
longer description, here "sitemap.html".
Please consult the section on the visual presentation of objects, images, and applets for
information about image size, alignment, and borders.
Attribute definitions
classid = uri
This attribute may be used to specify the location of an object's implementation via a
URI. It may be used together with, or as an alternative to the data attribute,
depending on the type of object involved.
codebase = uri
This attribute specifies the base path used to resolve relative URIs specified by the
classid, data, and archive attributes. When absent, its default value is the base URI of
the current document.
codetype = content-type
This attribute specifies the content type of data expected when downloading the
object specified by classid. This attribute is optional but recommended when classid
is specified since it allows the browser to avoid loading information for unsupported
content types. When absent, it defaults to the value of the type attribute.
data = uri
This attribute may be used to specify the location of the object's data, for instance
image data for objects defining images, or more generally, a serialized form of an
object which can be used to recreate it. If given as a relative URI, it should be
interpreted relative to the codebase attribute.
type = content-type
This attribute specifies the content type for the data specified by data. This attribute
is optional but recommended when data is specified since it allows the browser to
avoid loading information for unsupported content types. If the value of this attribute
differs from the HTTP Content-Type returned by the server when the object is
retrieved, the HTTP Content-Type takes precedence.
archive = uri-list
This attribute may be used to specify a space-separated list of URIs for archives
containing resources relevant to the object, which may include the resources
specified by the classid and data attributes. Preloading archives will generally result
in reduced load times for objects. Archives specified as relative URIs should be
interpreted relative to the codebase attribute.
declare
When present, this boolean attribute makes the current OBJECT definition a
declaration only. The object must be instantiated by a subsequent OBJECT definition
referring to this declaration.
standby = text
This attribute specifies a message that a browser may render while loading the
object's implementation and data.
Most browsers have built-in mechanisms for rendering common data types such as text, GIF
images, colors, fonts, and a handful of graphic elements. To render data types they don't
support natively, browsers generally run external applications. The OBJECT element allows
authors to control whether data should be rendered externally or by some program,
specified by the author, that renders the data within the browser.
In the most general case, an author may need to specify three types of information:
The implementation of the included object. For instance, if the included object is a
clock applet, the author must indicate the location of the applet's executable code.
The data to be rendered. For instance, if the included object is a program that
renders font data, the author must indicate the location of that data.
Additional values required by the object at run-time. For example, some applets may
require initial values for parameters.
The OBJECT element allows authors to specify all three types of data, but authors may not
have to specify all three at once. For example, some objects may not require data (e.g., a
self-contained applet that performs a small animation). Others may not require run-time
initialization. Still others may not require additional implementation information, i.e., the
browser itself may already know how to render that type of data (e.g., GIF images).
You can specify an object's implementation and the location of the data to be rendered via
the OBJECT element. To specify run-time values, however, authors use the PARAM element,
which is discussed in the section on object initialization.
The OBJECT element may also appear in the content of the HEAD element. Since browsers
generally do not render elements in the HEAD, authors should ensure that any OBJECT
elements in the HEAD do not specify content that may be rendered. Please consult the
section on sharing frame data for an example of including the OBJECT element in the HEAD
element.
Please consult the section on form controls for information about OBJECT elements in forms.
This document does not specify the behavior of OBJECT elements that use both the classid
attribute to identify an implementation and the data attribute to specify data for that
implementation. In order to ensure portability, authors should use the PARAM element to tell
implementations where to retrieve additional data.
<P><OBJECT classid="http://www.miamachina.it/analogclock.py">
</OBJECT>
Note that the clock will be rendered as soon as the browser interprets this OBJECT
declaration. It is possible to delay rendering of an object by first declaring the object
(described below).
Authors should complete this declaration by including alternate text as the contents of
OBJECT in case the browser cannot render the clock.
<P><OBJECT classid="http://www.miamachina.it/analogclock.py">
An animated clock.
</OBJECT>
One significant consequence of the OBJECT element's design is that it offers a mechanism
for specifying alternate object renderings; each embedded OBJECT declaration may specify
alternate content types. If a browser cannot render the outermost OBJECT, it tries to render
the contents, which may be another OBJECT element, etc.
In the following example, we embed several OBJECT declarations to illustrate how alternate
renderings work. A browser will attempt to render the first OBJECT element it can, in the
following order: (1) an Earth applet written in the Python language, (2) an MPEG animation of
the Earth, (3) a GIF image of the Earth, (4) alternate text.
<P> <!-- First, try the Python applet -->
<OBJECT title="The Earth as seen from space"
classid="http://www.observer.mars/TheEarth.py">
<!-- Else, try the MPEG video -->
<OBJECT data="TheEarth.mpeg" type="application/mpeg">
<!-- Else, try the GIF image -->
<OBJECT data="TheEarth.gif" type="image/gif">
<!-- Else render the text -->
The <STRONG>Earth</STRONG> as seen from space.
</OBJECT>
</OBJECT>
</OBJECT>
The outermost declaration specifies an applet that requires no data or initial values. The
second declaration specifies an MPEG animation and, since it does not define the location of
an implementation to handle MPEG, relies on the browser to handle the animation. We also
set the type attribute so that a browser that knows it cannot render MPEG will not bother to
retrieve "TheEarth.mpeg" from the network. The third declaration specifies the location of a
GIF file and furnishes alternate text in case all other mechanisms fail.
Attribute definitions
name = cdata
This attribute defines the name of a run-time parameter, assumed to be known by
the inserted object. Whether the property name is case-sensitive depends on the
specific object implementation.
value = cdata
This attribute specifies the value of a run-time parameter specified by name. Property
values have no meaning to HTML; their meaning is determined by the object in
question.
valuetype = data|ref|object
This attribute specifies the type of the value attribute. Possible values:
data: This is default value for the attribute. It means that the value specified
by value will be evaluated and passed to the object's implementation as a
string.
ref: The value specified by value is a URI that designates a resource where
run-time values are stored. This allows support tools to identify URIs given as
parameters. The URI must be passed to the object as is, i.e., unresolved.
object: The value specified by value is an identifier that refers to an OBJECT
declaration in the same document. The identifier must be the value of the id
attribute set for the declared OBJECT element.
type = content-type
This attribute specifies the content type of the resource designated by the value
attribute only in the case where valuetype is set to "ref". This attribute thus specifies
for the browser, the type of values that will be found at the URI designated by value.
PARAM elements specify a set of values that may be required by an object at run-time. Any
number of PARAM elements may appear in the content of an OBJECT or APPLET element, in
any order, but must be placed at the start of the content of the enclosing OBJECT or APPLET
element.
We return to the clock example to illustrate the use of PARAM: suppose that the applet is
able to handle two run-time parameters that define its initial height and width. We can set
the initial dimensions to 40x40 pixels with two PARAM elements.
<P><OBJECT classid="http://www.miamachina.it/analogclock.py">
<PARAM name="height" value="40" valuetype="data">
<PARAM name="width" value="40" valuetype="data">
This browser cannot render Python applications.
</OBJECT>
In the following example, run-time data for the object's "Init_values" parameter is specified
as an external resource (a GIF file). The value of the valuetype attribute is thus set to "ref"
and the value is a URI designating the resource.
<P><OBJECT classid="http://www.gifstuff.com/gifappli"
standby="Loading Elvis...">
<PARAM name="Init_values"
value="./images/elvis.gif">
valuetype="ref">
</OBJECT>
Note that we have also set the standby attribute so that the browser may display a message
while the rendering mechanism loads.
When an OBJECT element is rendered, browsers must search the content for only those
PARAM elements that are direct children and "feed" them to the OBJECT.
Thus, in the following example, if "obj1" is rendered, "param1" applies to "obj1" (and not
"obj2"). If "obj1" is not rendered and "obj2" is, "param1" is ignored, and "param2" applies to
"obj2". If neither OBJECT is rendered, neither PARAM applies.
<P>
<OBJECT id="obj1">
<PARAM name="param1">
<OBJECT id="obj2">
<PARAM name="param2">
</OBJECT>
</OBJECT>
To declare an object so that it is not executed when read by the browser, set the boolean
declare attribute in the OBJECT element. At the same time, authors must identify the
declaration by setting the id attribute in the OBJECT element to a unique value. Later
instantiations of the object will refer to this identifier.
A declared OBJECT must appear in a document before the first instance of that OBJECT.
An object defined with the declare attribute is instantiated every time an element that refers
to that object requires it to be rendered (e.g., a link that refers to it is activated, an object
that refers to it is activated, etc.).
The following example illustrates how to specify run-time values that are other objects. In
this example, we send text (a poem, in fact) to a hypothetical mechanism for viewing
poems. The object recognizes a run-time parameter named "font" (say, for rendering the
poem text in a certain font). The value for this parameter is itself an object that inserts (but
does not render) the font object. The relationship between the font object and the poem
viewer object is achieved by (1) assigning the id "tribune" to the font object declaration and
(2) referring to it from the PARAM element of the poem viewer object (with valuetype and
value).
<P><OBJECT declare
id="tribune"
type="application/x-webfont"
data="tribune.gif">
</OBJECT>
...view the poem in KublaKhan.txt here...
<P><OBJECT classid="http://foo.bar.com/poem_viewer"
data="KublaKhan.txt">
<PARAM name="font" valuetype="object" value="#tribune">
<P>You're missing a really cool poem viewer ...
</OBJECT>
When the applet is "deserialized" the start() method is invoked but not the init()
method. Attributes valid when the original object was serialized are not restored. Any
attributes passed to this APPLET instance will be available to the applet. Authors
should use this feature with extreme caution. An applet should be stopped before it is
serialized.
Either code or object must be present. If both code and object are given, it is an error
if they provide different class names.
width = length
This attribute specifies the initial width of the applet's display area (excluding any
windows or dialogs that the applet creates).
height = length
This attribute specifies the initial height of the applet's display area (excluding any
windows or dialogs that the applet creates).
This element, supported by all Java-enabled browsers, allows designers to embed a Java
applet in an HTML document. It has been deprecated in favor of the OBJECT element.
The content of the APPLET acts as alternate information for browsers that don't support this
element or are currently configured not to support applets. Browsers must ignore the
content otherwise.
DEPRECATED EXAMPLE:
In the following example, the APPLET element includes a Java applet in the document. Since
no codebase is supplied, the applet is assumed to be in the same directory as the current
document.
<APPLET code="Bubbles.class" width="500" height="500">
Java applet that draws animated bubbles.
</APPLET>
This example may be rewritten with OBJECT as follows:
<P><OBJECT codetype="application/java"
classid="java:Bubbles.class"
width="500" height="500">
Java applet that draws animated bubbles.
</OBJECT>
Initial values may be supplied to the applet via the PARAM element.
DEPRECATED EXAMPLE:
The following sample Java applet:
<APPLET code="AudioItem" width="15" height="15">
<PARAM name="snd" value="Hello.au|Welcome.au">
Java applet that plays a welcoming sound.
</APPLET>
may be rewritten as follows with OBJECT:
<OBJECT codetype="application/java"
classid="AudioItem"
width="15" height="15">
<PARAM name="snd" value="Hello.au|Welcome.au">
Java applet that plays a welcoming sound.
</OBJECT>
Image maps
Image maps allow authors to specify regions of an image or object and assign a specific
action to each region (e.g., retrieve a document, run a program, etc.) When the region is
activated by the user, the action is executed.
An image map is created by associating an object with a specification of sensitive geometric
areas on the object.
There are two types of image maps:
Client-side. When a user activates a region of a client-side image map with a mouse,
the pixel coordinates are interpreted by the browser. The browser selects a link that
was specified for the activated region and follows it.
Server-side. When a user activates a region of a server-side image map with a
mouse, the pixel coordinates of the click are sent to the server-side agent specified
by the href attribute of the A element. The server-side agent interprets the
coordinates and performs some action.
Client-side image maps are preferred over server-side image maps for at least two reasons:
they are accessible to people browsing with non-graphical browsers and they offer
immediate feedback as to whether or not the pointer is over an active region.
AREA
Start tag: required, End tag: forbidden
The MAP element specifies a client-side image map (or other navigation mechanism) that
may be associated with another elements (IMG, OBJECT, or INPUT). An image map is
associated with an element via the element's usemap attribute. The MAP element may be
used without an associated image for general navigation mechanisms.
The presence of the usemap attribute for an OBJECT implies that the object being included is
an image. Furthermore, when the OBJECT element has an associated client-side image map,
browsers may implement user interaction with the OBJECT solely in terms of the client-side
image map. This allows browsers (such as an audio browser or robot) to interact with the
OBJECT without having to process it; the browser may even elect not to retrieve (or process)
the object. When an OBJECT has an associated image map, authors should not expect that
the object will be retrieved or processed by every browser.
The MAP element content model allows authors to combine the following:
1. One or more AREA elements. These elements have no content but specify the
geometric regions of the image map and the link associated with each region. Note
that browsers do not generally render AREA elements. Therefore, authors must
provide alternate text for each AREA with the alt attribute (see below for information
on how to specify alternate text).
2. Block-level content. This content should include A elements that specify the
geometric regions of the image map and the link associated with each region. Note
that the browser should render block-level content of a MAP element. Authors should
use this method to create more accessible documents.
When a MAP element contains mixed content (both AREA elements and block-level content),
browsers must ignore the AREA elements.
You should specify an image maps's geometry completely with AREA elements, or
completely with A elements, or completely with both if content is mixed. Authors may wish
to mix content so that older browsers will handle map geometries specified by AREA
elements and new browsers will take advantage of richer block content.
If two or more defined regions overlap, the region-defining element that appears earliest in
the document takes precedence (i.e., responds to user input).
<MAP name="map1">
<P>Navigate the site:
<A href="guide.html" shape="rect" coords="0,0,118,28">Access Guide</a> |
<A href="shortcut.html" shape="rect" coords="118,0,184,28">Go</A> |
<A href="search.html" shape="circle" coords="184,200,60">Search</A> |
<A href="top10.html" shape="poly"
coords="276,0,276,28,100,200,50,50,276,0">Top Ten</A>
</MAP>
</BODY>
</HTML>
In the following example, we create a similar image map, this time using the AREA element.
Note the use of alt text:
<P><OBJECT data="navbar1.gif" type="image/gif" usemap="#map1">
<P>This is a navigation bar.
</OBJECT>
<MAP name="map1">
<AREA href="guide.html"
alt="Access Guide"
shape="rect"
coords="0,0,118,28">
<AREA href="search.html"
alt="Search"
shape="rect"
coords="184,0,276,28">
<AREA href="shortcut.html"
alt="Go"
shape="circle"
coords="184,200,60">
<AREA href="top10.html"
alt="Top Ten"
shape="poly"
coords="276,0,276,28,100,200,50,50,276,0">
</MAP>
Here is a similar version using the IMG element instead of OBJECT (with the same MAP
declaration):
<P><IMG src="navbar1.gif" usemap="#map1" alt="navigation bar">
The following example illustrates how image maps may be shared.
Nested OBJECT elements are useful for providing fallbacks in case a browser doesn't support
certain formats. For example:
<P>
<OBJECT data="navbar.png" type="image/png">
<OBJECT data="navbar.gif" type="image/gif">
text describing the image...
</OBJECT>
</OBJECT>
If the browser doesn't support the PNG format, it tries to render the GIF image. If it doesn't
support GIF (e.g., it's a speech-based browser), it defaults to the text description provided as
the content of the inner OBJECT element. When OBJECT elements are nested this way,
authors may share image maps among them:
<P>
<OBJECT data="navbar.png" type="image/png" usemap="#map1">
<OBJECT data="navbar.gif" type="image/gif" usemap="#map1">
<MAP name="map1">
<P>Navigate the site:
<A href="guide.html" shape="rect" coords="0,0,118,28">Access Guide</a> |
<A href="shortcut.html" shape="rect" coords="118,0,184,28">Go</A> |
<A href="search.html" shape="circle" coords="184,200,60">Search</A> |
<A href="top10.html" shape="poly"
coords="276,0,276,28,100,200,50,50,276,0">Top Ten</A>
</MAP>
</OBJECT>
</OBJECT>
The following example illustrates how anchors may be specified to create inactive zones
within an image map. The first anchor specifies a small circular region with no associated
link. The second anchor specifies a larger circular region with the same center coordinates.
Combined, the two form a ring whose center is inactive and whose rim is active. The order of
the anchor definitions is important, since the smaller circle must override the larger circle.
<MAP name="map1">
<P>
<A shape="circle" coords="100,200,50">I'm inactive.</A>
<A href="outer-ring-link.html" shape="circle" coords="100,200,250">I'm active.</A>
</MAP>
Similarly, the nohref attribute for the AREA element declares that geometric region has no
associated link.
It is only possible to define a server-side image map for the IMG and INPUT elements. In the
case of IMG, the IMG must be inside an A element and the boolean attribute ismap must be
set. In the case of INPUT, the INPUT must be of type "image".
When the user activates the link by clicking on the image, the screen coordinates are sent
directly to the server where the document resides. Screen coordinates are expressed as
screen pixel values relative to the image.
In the following example, the active region defines a server-side link. Thus, a click anywhere
on the image will cause the click's coordinates to be sent to the server.
<P><A href="http://www.acme.com/cgi-bin/competition">
<IMG src="game.gif" ismap alt="target"></A>
The location clicked is passed to the server as follows. The browser derives a new URI from
the URI specified by the href attribute of the A element, by appending `?' followed by the x
and y coordinates, separated by a comma. The link is then followed using the new URI. For
instance, in the given example, if the user clicks at the location x=10, y=27 then the derived
URI is "http://www.acme.com/cgi-bin/competition?10,27".
Browsers that do not offer the user a means to select specific coordinates (e.g., non-
graphical browsers that rely on keyboard input, speech-based browsers, etc.) should send
the coordinates "0,0" to the server when the link is activated.
When specified, the width and height attributes tell browsers to override the natural image
or object size in favor of these values.
When the object is an image, it is scaled. Browsers should do their best to scale an object or
image to match the width and height specified by the author. Note that lengths expressed as
percentages are based on the horizontal or vertical space currently available, not on the
natural size of the image, object, or applet.
The height and width attributes give browsers an idea of the size of an image or object so
that they may reserve space for it and continue rendering the document while waiting for
the image data.
Borders
An image or object may be surrounded by a border (e.g., when a border is specified by the
user or when the image is the content of an A element).
Attribute definitions
border = pixels
Deprecated. This attribute specifies the width of an IMG or OBJECT border, in pixels.
The default value for this attribute depends on the browser.
Alignment
Attribute definitions
align = bottom|middle|top|left|right
Deprecated. This attribute specifies the position of an IMG, OBJECT, or APPLET with
respect to its context.
The following values for align concern the object's position with respect to surrounding text:
bottom: means that the bottom of the object should be vertically aligned with the
current baseline. This is the default value.
middle: means that the center of the object should be vertically aligned with the
current baseline.
top: means that the top of the object should be vertically aligned with the top of the
current text line.
Two other values, left and right, cause the image to float to the current left or right margin.
They are discussed in the section on floating objects.
Several non-textual elements (IMG, AREA, APPLET, and INPUT) let authors specify alternate
text to serve as content when the element cannot be rendered normally. Specifying
alternate text assists users without graphic display terminals, users whose browsers don't
support forms, visually impaired users, those who use speech synthesizers, those who have
configured their graphical browsers not to display images, etc.
The alt attribute must be specified for the IMG and AREA elements. It is optional for the
INPUT and APPLET elements.
While alternate text may be very helpful, it must be handled with care. Authors should
observe the following guidelines:
Do not specify irrelevant alternate text when including images intended to format a
page, for instance, alt="red ball" would be inappropriate for an image that adds a red
ball for decorating a heading or paragraph. In such cases, the alternate text should
be the empty string (""). Authors are in any case advised to avoid using images to
format pages; style sheets should be used instead.
Do not specify meaningless alternate text (e.g., "dummy text"). Not only will this
frustrate users, it will slow down browsers that must convert text to speech or braille
output.
Implementors should consult the section on accessibility for information about how to handle
cases of omitted alternate text.
Forms
Introduction to forms
An HTML form is a section of a document containing normal content, markup, special
elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those
controls. Users generally "complete" a form by modifying its controls (entering text,
selecting menu items, etc.), before submitting the form to an agent for processing (e.g., to a
Web server, to a mail server, etc.)
Here's a simple form that includes labels, radio buttons, and push buttons (reset the form or
submit it):
<FORM action="http://somesite.com/prog/adduser" method="post">
<P>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" id="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" id="lastname"><BR>
<LABEL for="email">email: </LABEL>
<INPUT type="text" id="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</P>
</FORM>
Controls
Users interact with forms through named controls.
A control's "control name" is given by its name attribute. The scope of the name attribute for
a control within a FORM element is the FORM element.
Each control has both an initial value and a current value, both of which are character
strings. Please consult the definition of each control for information about initial values and
possible constraints on values imposed by the control. In general, a control's "initial value"
may be specified with the control element's value attribute. However, the initial value of a
TEXTAREA element is given by its contents, and the initial value of an OBJECT element in a
form is determined by the object implementation (i.e., it lies outside the scope of this
specification).
The control's "current value" is first set to the initial value. Thereafter, the control's current
value may be modified through user interaction and scripts.
A control's initial value does not change. Thus, when a form is reset, each control's current
value is reset to its initial value. If a control does not have an initial value, the effect of a
form reset on that control is undefined.
When a form is submitted for processing, some controls have their name paired with their
current value and these pairs are submitted with the form. Those controls for which
name/value pairs are submitted are called successful controls.
Control types
HTML defines the following control types:
buttons
Authors may create three types of buttons:
submit buttons: When activated, a submit button submits a form. A form may
contain more than one submit button.
reset buttons: When activated, a reset button resets all controls to their initial
values.
push buttons: Push buttons have no default behavior. Each push button may
have client-side scripts associated with the element's event attributes. When
an event occurs (e.g., the user presses the button, releases it, etc.), the
associated script is triggered.
Authors should specify the scripting language of a push button script through
a default script declaration (with the META element).
Authors create buttons with the BUTTON element or the INPUT element. Please
consult the definitions of these elements for details about specifying different button
types.
checkboxes
Checkboxes (and radio buttons) are on/off switches that may be toggled by the user.
A switch is "on" when the control element's checked attribute is set. When a form is
submitted, only "on" checkbox controls can become successful.
Several checkboxes in a form may share the same control name. Thus, for example,
checkboxes allow users to select several values for the same property. The INPUT
element is used to create a checkbox control.
radio buttons
Radio buttons are like checkboxes except that when several share the same control
name, they are mutually exclusive: when one is switched "on", all others with the
same name are switched "off". The INPUT element is used to create a radio button
control.
menus
Menus offer users options from which to choose. The SELECT element creates a
menu, in combination with the OPTGROUP and OPTION elements.
text input
Authors may create two types of controls that allow users to input text. The INPUT
element creates a single-line input control and the TEXTAREA element creates a
multi-line input control. In both cases, the input text becomes the control's current
value.
file select
This control type allows the user to select files so that their contents may be
submitted with a form. The INPUT element is used to create a file select control.
hidden controls
Authors may create controls that are not rendered but whose values are submitted
with a form. Authors generally use this control type to store information between
client/server exchanges that would otherwise be lost due to the stateless nature of
HTTP. The INPUT element is used to create a hidden control.
object controls
Authors may insert generic objects in forms such that associated values are
submitted along with other controls. Authors create object controls with the OBJECT
element.
The elements used to create controls generally appear inside a FORM element, but may also
appear outside of a FORM element declaration when they are used to build user interfaces.
This is discussed in the section on intrinsic events. Note that controls outside a form cannot
be successful controls.
Attribute definitions
action = uri
This attribute specifies a form processing agent. Browser behavior for a value other
than an HTTP URI is undefined.
method = get|post
This attribute specifies which HTTP method will be used to submit the form data set.
Possible (case-insensitive) values are "get" (the default) and "post". See the section
on form submission for usage information.
enctype = content-type
This attribute specifies the content type used to submit the form to the server (when
the value of method is "post"). The default value for this attribute is "application/x-
www-form-urlencoded". The value "multipart/form-data" should be used in
combination with the INPUT element, type="file".
accept-charset = charset list
This attribute specifies the list of character encodings for input data that is accepted
by the server processing this form. The value is a space- and/or comma-delimited list
of charset values. The client must interpret this list as an exclusive-or list, i.e., the
server is able to accept any single character encoding per entity received.
The default value for this attribute is the reserved string "UNKNOWN". Browsers may
interpret this value as the character encoding that was used to transmit the
document containing this FORM element.
accept = content-type-list
This attribute specifies a comma-separated list of content types that a server
processing this form will handle correctly. Browsers may use this information to filter
out non-conforming files when prompting a user to select files to be sent to the server
(cf. the INPUT element when type="file").
name = cdata
This attribute names the element so that it may be referred to from style sheets or
scripts. Note. This attribute has been included for backwards compatibility.
Applications should use the id attribute to identify elements.
The FORM element acts as a container for controls. It specifies:
The layout of the form (given by the contents of the element).
The program that will handle the completed and submitted form (the action
attribute). The receiving program must be able to parse name/value pairs in order to
make use of them.
The method by which user data will be sent to the server (the method attribute).
A character encoding that must be accepted by the server in order to handle this
form (the accept-charset attribute). Browsers may advise the user of the value of the
accept-charset attribute and/or restrict the user's ability to enter unrecognized
characters.
A form can contain text and markup (paragraphs, lists, etc.) in addition to form controls.
The following example shows a form that is to be processed by the "adduser" program when
submitted. The form will be sent to the program using the HTTP "post" method.
<FORM action="http://somesite.com/prog/adduser" method="post">
...form contents...
</FORM>
Please consult the section on form submission for information about how browsers must
prepare form data for servers and how browsers should handle expected responses.
Attribute definitions
type = text|password|checkbox|radio|submit|reset|file|hidden|image|button
This attribute specifies the type of control to create. The default value for this
attribute is "text".
name = cdata
This attribute assigns the control name.
value = cdata
This attribute specifies the initial value of the control. It is optional except when the
type attribute has the value "radio" or "checkbox".
size = cdata
This attribute tells the browser the initial width of the control. The width is given in
pixels except when type attribute has the value "text" or "password". In that case, its
value refers to the (integer) number of characters.
maxlength = number
When the type attribute has the value "text" or "password", this attribute specifies
the maximum number of characters the user may enter. This number may exceed
the specified size, in which case the browser should offer a scrolling mechanism. The
default value for this attribute is an unlimited number.
checked
When the type attribute has the value "radio" or "checkbox", this boolean attribute
specifies that the button is on. Browsers must ignore this attribute for other control
types.
src = uri
When the type attribute has the value "image", this attribute specifies the location of
the image to be used to decorate the graphical submit button.
Note. Application designers should note that this mechanism affords only light
security protection. Although the password is masked by browsers from casual
observers, it is transmitted to the server in clear text, and may be read by anyone
with low-level access to the network.
checkbox
Creates a checkbox.
radio
Creates a radio button.
submit
Creates a submit button.
image
Creates a graphical submit button. The value of the src attribute specifies the URI of
the image that will decorate the button. For accessibility reasons, authors should
provide alternate text for the image via the alt attribute.
When a pointing device is used to click on the image, the form is submitted and the
click coordinates passed to the server. The x value is measured in pixels from the left
of the image, and the y value in pixels from the top of the image. The submitted data
includes name.x=x-value and name.y=y-value where "name" is the value of the
name attribute, and x-value and y-value are the x and y coordinate values,
respectively.
If the server takes different actions depending on the location clicked, users of non-
graphical browsers will be disadvantaged. For this reason, authors should consider
alternate approaches:
Use multiple submit buttons (each with its own image) in place of a single
graphical submit button. Authors may use style sheets to control the
positioning of these buttons.
Use a client-side image map together with scripting.
reset
Creates a reset button.
button
Creates a push button. Browsers should use the value of the value attribute as the
button's label.
hidden
Creates a hidden control.
file
Creates a file select control. Browsers may use the value of the value attribute as the
initial file name.
In this next example, the JavaScript function name verify is triggered when the "onclick"
event occurs:
<HEAD>
<META http-equiv="Content-Script-Type" content="text/javascript">
</HEAD>
<BODY>
<FORM action="..." method="post">
<P>
<INPUT type="button" value="Click Me" onclick="verify()">
</FORM>
</BODY>
Please consult the section on intrinsic events for more information about scripting and
events.
The following example shows how the contents of a user-specified file may be submitted
with a form. The user is prompted for his or her name and a list of file names whose contents
should be submitted with the form. By specifying the enctype value of "multipart/form-data",
each file's contents will be packaged for submission in a separate section of a multipart
document.
<FORM action="http://server.dom/cgi/handle"
enctype="multipart/form-data"
method="post">
<P>
What is your name? <INPUT type="text" name="name_of_sender">
What files are you sending? <INPUT type="file" name="name_of_files">
</P>
</FORM>
Attribute definitions
name = cdata
This attribute assigns the control name.
value = cdata
This attribute assigns the initial value to the button.
type = submit|button|reset
This attribute declares the type of the button. Possible values:
submit: Creates a submit button. This is the default value.
reset: Creates a reset button.
button: Creates a push button.
Buttons created with the BUTTON element function just like buttons created with the INPUT
element, but they offer richer rendering possibilities: the BUTTON element may have
content. For example, a BUTTON element that contains an image functions like and may
resemble an INPUT element whose type is set to "image", but the BUTTON element type
allows content.
Visual browsers may render BUTTON buttons with relief and an up/down motion when
clicked, while they may render INPUT buttons as "flat" images.
The following example expands a previous example, but creates submit and reset buttons
with BUTTON instead of INPUT. The buttons contain images by way of the IMG element.
<FORM action="http://somesite.com/prog/adduser" method="post">
<P>
First name: <INPUT type="text" name="firstname"><BR>
Last name: <INPUT type="text" name="lastname"><BR>
email: <INPUT type="text" name="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<BUTTON name="submit" value="submit" type="submit">
Send<IMG src="/icons/wow.gif" alt="wow"></BUTTON>
<BUTTON name="reset" type="reset">
Reset<IMG src="/icons/oops.gif" alt="oops"></BUTTON>
</P>
</FORM>
Recall that authors must provide alternate text for an IMG element.
It is illegal to associate an image map with an IMG that appears as the contents of a BUTTON
element.
ILLEGAL EXAMPLE:
The following is not legal HTML.
<BUTTON>
<IMG src="foo.gif" usemap="...">
</BUTTON>
The SELECT element creates a menu. Each choice offered by the menu is represented by an
OPTION element. A SELECT element must contain at least one OPTION element.
The OPTGROUP element allows authors to group choices logically. This is particularly helpful
when the user must choose from a long list of options; groups of related choices are easier
to grasp and remember than a single long list of options. In HTML 4, all OPTGROUP elements
must be specified directly within a SELECT element (i.e., groups may not be nested).
OPTGROUP
Start tag: required, End tag: required
OPTION
Start tag: required, End tag: optional
In this example, we create a menu that allows the user to select which of seven software
components to install. The first and second components are pre-selected but may be
deselected by the user. The remaining components are not pre-selected. The size attribute
states that the menu should only have 4 rows even though the user may select from among
7 options. The other options should be made available through a scrolling mechanism.
In this example we use the OPTGROUP element to group choices. The following markup:
<FORM action="http://somesite.com/prog/someprog" method="post">
<P>
<SELECT name="ComOS">
<OPTION selected label="none" value="none">None</OPTION>
<OPTGROUP label="PortMaster 3">
<OPTION label="3.7.1" value="pm3_3.7.1">PortMaster 3 with ComOS
3.7.1</OPTION>
<OPTION label="3.7" value="pm3_3.7">PortMaster 3 with ComOS 3.7</OPTION>
<OPTION label="3.5" value="pm3_3.5">PortMaster 3 with ComOS 3.5</OPTION>
</OPTGROUP>
<OPTGROUP label="PortMaster 2">
<OPTION label="3.7" value="pm2_3.7">PortMaster 2 with ComOS 3.7</OPTION>
<OPTION label="3.5" value="pm2_3.5">PortMaster 2 with ComOS 3.5</OPTION>
</OPTGROUP>
<OPTGROUP label="IRX">
<OPTION label="3.7R" value="IRX_3.7R">IRX with ComOS 3.7R</OPTION>
<OPTION label="3.5R" value="IRX_3.5R">IRX with ComOS 3.5R</OPTION>
</OPTGROUP>
</SELECT>
</FORM>
represents the following grouping:
None
PortMaster 3
3.7.1
3.7
3.5
PortMaster 2
3.7
3.5
IRX
3.7R
3.5R
Visual browsers may allow users to select from option groups through a hierarchical menu or
some other mechanism that reflects the structure of choices.
A graphical browser might render this as:
This image shows a SELECT element rendered as cascading menus. The top label of the
menu displays the currently selected value (PortMaster 3, 3.7.1). The user has unfurled two
cascading menus, but has not yet selected the new value (PortMaster 2, 3.7). Note that each
cascading menu displays the label of an OPTGROUP or OPTION element.
Attribute definitions
name = cdata
This attribute assigns the control name.
rows = number
This attribute specifies the number of visible text lines. Users should be able to enter
more lines than this, so browsers should provide some means to scroll through the
contents of the control when the contents extend beyond the visible area.
cols = number
This attribute specifies the visible width in average character widths. Users should be
able to enter longer lines than this, so browsers should provide some means to scroll
through the contents of the control when the contents extend beyond the visible
area. Browsers may wrap visible text lines to keep long lines visible without the need
for scrolling.
The TEXTAREA element creates a multi-line text input control. Browsers should use the
contents of this element as the initial value of the control and should render this text
initially.
This example creates a TEXTAREA control that is 20 rows by 80 columns and contains two
lines of text initially. The TEXTAREA is followed by submit and reset buttons.
<FORM action="http://somesite.com/prog/text-read" method="post">
<P>
<TEXTAREA name="thetext" rows="20" cols="80">
First line of initial text.
Second line of initial text.
</TEXTAREA>
<INPUT type="submit" value="Send"><INPUT type="reset">
</P>
</FORM>
Setting the readonly attribute allows authors to display unmodifiable text in a TEXTAREA.
This differs from using standard marked-up text in a document because the value of
TEXTAREA is submitted with the form.
Attribute definitions
prompt = text
Deprecated. This attribute specifies a prompt string for the input field.
The ISINDEX element creates a single-line text input control that allows any number of
characters. Browsers may use the value of the prompt attribute as a title for the prompt.
DEPRECATED EXAMPLE:
The following ISINDEX declaration:
<ISINDEX prompt="Enter your search phrase: ">
could be rewritten with INPUT as follows:
<FORM action="..." method="post">
<P>Enter your search phrase: <INPUT type="text"></P>
</FORM>
Labels
Some form controls automatically have labels associated with them (press buttons) while
most do not (text fields, checkboxes and radio buttons, and menus).
For those controls that have implicit labels, browsers should use the value of the value
attribute as the label string.
The LABEL element is used to specify labels for controls that do not have implicit labels,
Attribute definitions
for = idref
This attribute explicitly associates the label being defined with another control. When
present, the value of this attribute must be the same as the value of the id attribute
of some other control in the same document. When absent, the label being defined is
associated with the element's contents.
The LABEL element may be used to attach information to controls. Each LABEL element is
associated with exactly one form control.
The for attribute associates a label with another control explicitly: the value of the for
attribute must be the same as the value of the id attribute of the associated control element.
More than one LABEL may be associated with the same control by creating multiple
references via the for attribute.
This example creates a table that is used to align two text input controls and their
associated labels. Each label is associated explicitly with one text input:
<FORM action="..." method="post">
<TABLE>
<TR>
<TD><LABEL for="fname">First Name</LABEL>
<TD><INPUT type="text" name="firstname" id="fname">
<TR>
<TD><LABEL for="lname">Last Name</LABEL>
<TD><INPUT type="text" name="lastname" id="lname">
</TABLE>
</FORM>
This example extends a previous example form to include LABEL elements.
<FORM action="http://somesite.com/prog/adduser" method="post">
<P>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" id="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" id="lastname"><BR>
<LABEL for="email">email: </LABEL>
<INPUT type="text" id="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</P>
</FORM>
To associate a label with another control implicitly, the control element must be within the
contents of the LABEL element. In this case, the LABEL may only contain one control
element. The label itself may be positioned before or after the associated control.
In this example, we implicitly associate two labels with two text input controls:
<FORM action="..." method="post">
<P>
<LABEL>
First Name
<INPUT type="text" name="firstname">
</LABEL>
<LABEL>
<INPUT type="text" name="lastname">
Last Name
</LABEL>
</P>
</FORM>
Note that this technique cannot be used when a table is being used for layout, with the label
in one cell and its associated control in another cell.
When a LABEL element receives focus, it passes the focus on to its associated control. See
the section below on access keys for examples.
Labels may be rendered by browsers in a number of ways (e.g., visually, read by speech
synthesizers, etc.)
Tabbing navigation
Attribute definitions
tabindex = number
This attribute specifies the position of the current element in the tabbing order for the
current document. This value must be a number between 0 and 32767. Browsers
should ignore leading zeros.
The tabbing order defines the order in which elements will receive focus when navigated by
the user via the keyboard. The tabbing order may include elements nested within other
elements.
Elements that may receive focus should be navigated by browsers according to the following
rules:
1. Those elements that support the tabindex attribute and assign a positive value to it
are navigated first. Navigation proceeds from the element with the lowest tabindex
value to the element with the highest value. Values need not be sequential nor must
they begin with any particular value. Elements that have identical tabindex values
should be navigated in the order they appear in the character stream.
2. Those elements that do not support the tabindex attribute or support it and assign it
a value of "0" are navigated next. These elements are navigated in the order they
appear in the character stream.
3. Elements that are disabled do not participate in the tabbing order.
The following elements support the tabindex attribute: A, AREA, BUTTON, INPUT, OBJECT,
SELECT, and TEXTAREA.
In this example, the tabbing order will be the BUTTON, the INPUT elements in order (note
that "field1" and the button share the same tabindex, but "field1" appears later in the
character stream), and finally the link created by the A element.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>A document with FORM</TITLE>
</HEAD>
<BODY>
...some text...
<P>Go to the
<A tabindex="10" href="http://www.w3.org/">W3C Web site.</A>
...some more...
<BUTTON type="button" name="get-database"
tabindex="1" onclick="get-database">
Get the current database.
</BUTTON>
...some more...
<FORM action="..." method="post">
<P>
<INPUT tabindex="1" type="text" name="field1">
<INPUT tabindex="2" type="text" name="field2">
<INPUT tabindex="3" type="submit" name="submit">
</P>
</FORM>
</BODY>
</HTML>
Tabbing keys. The actual key sequence that causes tabbing navigation or element
activation depends on the configuration of the browser (e.g., the "tab" key is used for
navigation and the "enter" key is used to activate a selected element).
Browsers may also define key sequences to navigate the tabbing order in reverse. When the
end (or beginning) of the tabbing order is reached, browsers may circle back to the
beginning (or end).
Access keys
Attribute definitions
accesskey = character
This attribute assigns an access key to an element. An access key is a single
character from the document character set. Note. Authors should consider the input
method of the expected reader when specifying an accesskey.
Pressing an access key assigned to an element gives focus to the element. The action that
occurs when an element receives focus depends on the element. For example, when a user
activates a link defined by the A element, the browser generally follows the link. When a
user activates a radio button, the browser changes the value of the radio button. When the
user activates a text field, it allows input, etc.
The following elements support the accesskey attribute: A, AREA, BUTTON, INPUT, LABEL,
and LEGEND, and TEXTAREA.
This example assigns the access key "U" to a label associated with an INPUT control. Typing
the access key gives focus to the label which in turn gives it to the associated control. The
user may then enter text into the INPUT area.
<FORM action="..." method="post">
<P>
<LABEL for="fuser" accesskey="U">
User Name
</LABEL>
<INPUT type="text" name="user" id="fuser">
</P>
</FORM>
In this example, we assign an access key to a link defined by the A element. Typing this
access key takes the user to another document, in this case, a table of contents.
<P><A accesskey="C"
rel="contents"
href="http://someplace.com/specification/contents.html">
Table of Contents</A>
The invocation of access keys depends on the underlying system. For instance, on machines
running MS Windows, one generally has to press the "alt" key in addition to the access key.
On Apple systems, one generally has to press the "cmd" key in addition to the access key.
The rendering of access keys depends on the browser. We recommend that authors include
the access key in label text or wherever the access key is to apply. Browsers should render
the value of an access key in such a way as to emphasize its role and to distinguish it from
other characters (e.g., by underlining it).
Note. The only way to modify dynamically the value of the disabled attribute is through a
script.
Read-only controls
Attribute definitions
readonly
When set for a form control, this boolean attribute prohibits changes to the control.
The readonly attribute specifies whether the control may be modified by the user.
When set, the readonly attribute has the following effects on an element:
Read-only elements receive focus but cannot be modified by the user.
Read-only elements are included in tabbing navigation.
Read-only elements may be successful.
The following elements support the readonly attribute: INPUT and TEXTAREA.
How read-only elements are rendered depends on the browser.
Note. The only way to modify dynamically the value of the readonly attribute is through a
script.
Form submission
The following sections explain how browsers submit form data to form processing agents.
Form submission method
The method attribute of the FORM element specifies the HTTP method used to send the form
to the processing agent. This attribute may take two values:
get: With the HTTP "get" method, the form data set is appended to the URI specified
by the action attribute (with a question-mark ("?") as separator) and this new URI is
sent to the processing agent.
post: With the HTTP "post" method, the form data set is included in the body of the
form and sent to the processing agent.
The "get" method should be used when the form is idempotent (i.e., causes no side-effects).
Many database searches have no visible side-effects and make ideal applications for the
"get" method.
If the service associated with the processing of a form causes side effects (for example, if
the form modifies a database or subscription to a service), the "post" method should be
used.
Note. The "get" method restricts form data set values to ASCII characters. Only the "post"
method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646]
character set.
Frames
Frames divide browser windows into several independent sections that can each containing
separate HTML document. Subdividing browser windows can dramatically improve the
appearance and the usability of a site.
Frames can, however, make navigation difficult. Framed sites use a combination of HTML
documents displayed together in the browser. Most commonly, frames divide the window
into two or more sections, with one larger section containing content and the smaller
section(s) containing a logo navigation links, or both. The appearance of frames depends on
how you design them.
Creating Frames:
Creating frames requires relatively few steps:
1. Create a frameset (or layout) document that determines the location and characteristics
of frames.
2. Designate the frames and their contents.
3. Format the frames.
4. Make provisions for frames when viewed in nonframed browsers.
Note: A framset specifies the layout for frames, including the locations and characteristics of
the frames, the framset acts as a holder for frame information.
FRAMSET TAGS AND ATTRIBUTES
Tags/Attribute Use
<FRAMSET> Establishes frames within HTML document.
ROW = “n1,n2” Sets the size for rows-horizontal frames in pixels, as a percentage, or
as proportion of the remaining space with ‘*’
COL = “n1,n2” Sets the size for columns-vertical frames in pixels, as a percentage, or
as proportion of the remaining space with ‘*’
<FRAME> Identifies frame characteristics and initial content.
SRC = “URL” Identifies the source for the frame content as a standard URL.
NAME = “….” Labels a frame so that it can be targeted or referred to from other
frames or windows.
<NOFRAMES> Sets a section of an HTML document to be visible to nonframed
browser (and invisible to framed browsers).
Creating a Frameset
A frameset is the foundation for individual frames and their content, and in it you
specify the general frame layout either vertical (using columns) or horizontal (using rows).
The basic frameset closely resembles a standard HTML document, but often lacks the
<BODY> tag.
Follow these steps to add frameset on your HTML documents.
1. Start with a basic HTML document, including <HTML>, <HEAD> an d <TITLE> tags and
<META> tags of your choice. Your code should look something like this:
<HTML>
<HEAD>
<TITLE> Frameset Samples</TITLE>
</HEAD>
</HTML>
2. Add <FRAMESET> tags to establish frameset:
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
<FRAMESET>
</FRAMESET>
<HEAD>
<HTML>
3. Add a COLS = or ROWS = attribute, depending on whether you want vertical or
horizontal frames. We used the COLS = attribute with values of 50% and * to get two
columns, one at 50% and one filling the remaining space:
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
</FRAMESET>
</HTML>
Within a frameset, you can specify either rows or columns, but not both. To divide
your browser window into columns and then subdivide each column into rows, you nest
<FRAMESET> tags like this:
<FRAMESET COLS = “200, 50%,*”>
<FRAMESET ROWS = “100,*”>
</FRAMESET>
</FRAMESET>
Adding Frames:
Adding frames to an existing frameset document is straightforward. You add a frame tag for
each column or in the frameset document, specify the content for each frame, and then
name each frame.
In the following example, we are going to add vertical frames. The process for adding
horizontal frames is the same except for the ROWS = or COLS = attribute in the
<FRAMESET> tag.
We’ll start with the existing frameset document that we created in the last section, and this
we’ll add two frame tags and the content for each frame. The starting document looks like
this:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
</FRAMESET>
</HTML>
Now follow these steps:
1. Add a <FRAME> tag within the <FRAMESET>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
<FRAME>
</FRAMESET>
</HTML>
2. Add the NAME = attribute to label the frame. Because browsers fill frames from left to
right and top to bottom, this frame is for the left frame. The second frame is for the right
frame.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
<FRAME NAME = “first”>
</FRAMESET>
</HTML>
3. Add the SRC = attribute to specify the HTML document that will fill the frame. The
document filling this frame is z-yellow.html.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
<FRAME NAME = “first” SRC = z-yellow.html”>
</FRAMESET>
</HTML>
4. Add the second frame tag, with the name second and source of z-blue.html.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Frameset Samples</TITLE>
</HEAD>
<FRAMESET COLS = “50%,*”>
<FRAME NAME = “first” SRC = z-yellow.html”>
<FRAME NAME = “second” SRC = z-blue.html”>
</FRAMESET>
</HTML>
Note: The URL use depends on where the file is located. If you’re using a file in the same
folder as the frameset document or in an adjacent folder, you can use a relative URL.
If the fire is located elsewhere, you will need to adjust the URL accordingly.
Formatting Framesets
Formatting a frame primarily involves changing its boarders and adjusting its margins. You
use the attributes shown below. These tags generally apply either to a <FRAMESET> tag and
thus to all <FRAME> tags within the frameset or to individual <FRAME> tags, although the
HTML 4 specification only supports using these attributes with individual <FRAME> tags.
You know the exact size of only the first frame; it will be 400 pixels wide and 100 pixels high.
All other frames on the page will be resized according to the size of the browser window. If
the browser window is set 800×600, the second (variable) column will be about 400 pixels
wide. If the browser window is 2024×786, however, the variable column will be about 600
pixels wide.
You can also set a frame to NORESIZE to prevent visitors from resizing it. Although many
Web surfers do not know that they can resize frames by simply clicking and dragging the
borders, some do and will rearrange the boarders to suit themselves, if, however, visitors
resize a frameset to avoid scrolling, they might obscure some content without realizing it. To
avoid this, simply add NORESIZE attribute to the <FRAME> tag, like this:
<FRAME NAME = “menu” SRC = “imagemap.html” NORESIZE>
NOTE: Setting one frame to NORESIZE also prohibits other frames from resizing.
Controlling Scrollbars:
Although scrollbars are essential to allow visitors to see all the content in most frames, they
can be superfluous and visually distracting. For example, depending on the margin that
browser inserts around an image, scrollbar might appear in some browsers on some platform
and not in others. If the entire image map fits within the frame, little scrolling is necessary,
and scrolling would probably obscure more of the image map than might be lost through the
margins. Therefore, you might set this frame to SCROLLING = no to prohibit scrollbars, like
this:
<FRAME NAME = “menu” SRC = “imagemap.html” SCROLLING = NO>
You can also put SCROLLING = NO in the <FRAMESET> tag if you want to prohibit scrolling
in all frameset document keep in mind, though, that if you turn off the scrollbars in a frame
containing more content than will fit in the window, your visitor will have no way to view the
page.
Setting frame margins
A frame margin is the space between the edge of the frame and the visible content of the
HTML document. Adjusting the frame margin affects the framed document itself and keeps
from appearing to touch each other; in other words, adjusting the frame margins gives you
document a little “breathing room”.
To set frame margins, and the MARGINHEIGHT = (for vertical margins) and MARGINWIDTH =
(for horizontal margins) attributes to the <FRAME> tag a shown in the following code:
<FRAME NAME = “topleft” SRC = “z=maroon.html” MARGINWIDTH = “100”
MARGINHEIGHT = “100”>
Linking to specific frames requires only one new attribute, TARGET = when used in an
anchor tag, this attribute directs the content of the link into a different frame.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>Computer Point Nepal</TITLE>
</HEAD>
<FRAMSET COLS = “230,*”
<FRAME NAME = “left” SRC = “leftoc1.html”>
<FRAME NAME = “main” SRC = “content.html”>
<NOFRAMES>
If you can see this, your browser is not capable of displaying frames.
</NOFRAMES>
</FRAMESET>
</HTML>
This first (left) <FRAME> tag carries the attribute NAME = “left”, and the other frame has
the attribute NAME = “main”. These attributes allow the frames to be specially addressed.
As the document currently stands, clicking a link-say, introduction-in the left frames the new
document in the left (same) frame because frame links, by default, and land in the same
frame. If you want the linked document to appear in the right frame, follow these steps:
1. Add the TARGET = attribute to the anchor tag.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>computer Point Nepal </TITLE>
</HEAD>
<BODY BACKGROUND = “.” BGCOLOR = “#ffffff” TEXT = “#000000” LINK = “#0000ff”
VLINK = “#8000080” ALINK = “#ff000000”>
<IMG SRC = “comput.gif” ALIGN = “.” WIDTH = “200” HEIGHT= “84” BOARDER = “0” ALT =
“.”>
<UL>
<LI><A HREF = “first.html” TARGET= “.”>Introduction</A>
<LI><A HERF = “services.html”>Services</A>
<LI><A HERF = “eduction.html”>Education</A>
<LI><A HERF = “software.html”>Software Development</A>
<LI><A HERF = “hardware.html”>Hardware Education</A>
</UL>
</BODY>
</HTML>
2. Add the name of the frame to which you want to link. The initial frameset names right
frames “main” frames, so that’s the name you use.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>computer Point Nepal </TITLE>
</HEAD>
<BODY BACKGROUND = “.” BGCOLOR = “#ffffff” TEXT = “#000000” LINK = “#0000ff”
VLINK = “#8000080” ALINK = “#ff000000”>
<IMG SRC = “comput.gif” ALIGN = “.” WIDTH = “200” HEIGHT= “84” BOARDER = “0” ALT =
“.”>
<UL>
<LI><A HREF = “first.html” TARGET= “main”>Introduction</A>
<LI><A HERF = “services.html”>Services</A>
<LI><A HERF = “eduction.html”>Education</A>
<LI><A HERF = “software.html”>Software Development</A>
<LI><A HERF = “hardware.html”>Hardware Education</A>
</UL>
</BODY>
</HTML>
When you click the introduction link, the file appears in the right frame.
Of course, in this particular scenario, each link from this document should open in the
main frame. To save time and reduce the possibility of error, you can ad the TARGET =
“main” attribute to the <BASE> tag and force it to affect the entire document.
The <BASE> tag goes in the document head and sets the rules for the whole
document. To set all links from the document in the left frame to open in the main frame,
and the tag and attribute to the document head as in the following example.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Farmeset//EN”>
<HTML>
<HEAD>
<TITLE>computer Point Nepal </TITLE>
<BASE TARGET = “main”>
</HEAD>
<BODY BACKGROUND = “.” BGCOLOR = “#ffffff” TEXT = “#000000” LINK = “#0000ff”
VLINK = “#8000080” ALINK = “#ff000000”>
<IMG SRC = “comput.gif” ALIGN = “.” WIDTH = “200” HEIGHT= “84” BOARDER = “0” ALT =
“.”>
<UL>
<LI><A HREF = “first.html” TARGET= “main”>Introduction</A>
<LI><A HERF = “services.html”>Services</A>
<LI><A HERF = “eduction.html”>Education</A>
<LI><A HERF = “software.html”>Software Development</A>
<LI><A HERF = “hardware.html”>Hardware Education</A>
</UL>
</BODY>
</HTML>
THE END