The vast range of HTML markup currently supported by available HTML user agents (Web browsers, such as Netscape, Mosaic, and so on) can be broadly divided into the following sections. Some elements described may not be supported by all browsers. Where an element is known to be supported by specific browsers, the element description will be labelled as such.
This appendix is divided into the following sections:
Document Structure Elements
Anchor Element
Block Formatting Elements
Character Data
Document Sound
Dynamic Documents
Forms
Inline Images
Information-Type and Character-Formatting Elements
List Elements
Tables
| Note |
Stephen Le Hunte (cmlehunt@swan.ac.uk), the author of this appendix, is an independent software developer and freelance technical author specialising in HTML and WinHelp. He is currently studying for his Ph.D. at the University of Wales Swansea. |
These elements are required within an HTML document. Apart from the prologue document identifier, they represent the only HTML elements that are explicitly required for a document to conform to the standard.
The essential document structure elements are
<HTML>...</HTML>
<HEAD>...</HEAD>
<BODY>...</BODY>
In order to identify a document as HTML, each HTML document should start with the prologue:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">.
However, it is worth noting that if the document does not contain this type declaration, a browser should infer it. This document identifier identifies the document as conforming to the HTML 2.0 DTD.
The <HTML> element identifies the document as containing HTML elements. It should immediately follow the prologue document identifier, and it serves to surround all of the remaining text, including all other elements. Browsers use the presence of this element at the start of an HTML document to ensure that the document is actually HTML, according to the text/html MIME type. The document should be constructed like this:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
The rest of the document should be placed here.
</HTML>
The HTML element is not visible upon browser rendering and can contain only the <HEAD> and <BODY> elements.
The <HEAD> element of an HTML document is used to provide information about the document. It requires the <TITLE> element between <HEAD> and </HEAD> tags:
<HEAD>
<TITLE>Introduction to HTML</TITLE>
</HEAD>
The <HEAD> and </HEAD> tags do not directly affect the look of the document when rendered.
The following elements are related to the <HEAD>
element. Although they don't directly affect the look of the document
when rendered, you can use them to provide important information
to the browser. To do so, you employ the following elements, all
of which should be included within the <HTML>...</HTML>
tags.
| <BASE> | Allows the base address of the HTML document to be specified |
| <ISINDEX> | Allows keyword searching of the document |
| <LINK> | Indicates relationships between documents |
| <META> | Specifies document information usable by server/clients |
| <NEXTID> | Creates unique document identifiers |
| <STYLE> | Specifies styles within the document when used by browsers that support use of style sheets |
| <TITLE> | Specifies the title of the document |
| Note |
The <TITLE> element is the only element described here that is required as part of the <HEAD> of an HTML document for conformance to any HTML standard. |
The <BODY> element of an HTML document, as its name suggests, contains all the text and images that make up the page, as well as all the HTML elements that provide the control and formatting of the page. The format is
<BODY>
The rest of the document included here
</BODY>
The <BODY>...</BODY> tags should be directly enclosed within the <HTML>...</HTML> tags.
The <BODY> and </BODY> tags themselves do not directly affect the look of the document when rendered, but they are required in order for the document to conform to the specification standard. Various attributes of the opening <BODY> tag can be used to set up various page-formatting settings.
The capability to specify background images and colors for HTML documents was first implemented by Netscape and has since been implemented by most other browsers. It should be noted that the following elements might not be supported by every browser.
Recent versions of the proposed HTML 3.2 specification have added a BACKGROUND attribute to the <BODY> element. The purpose of this attribute is to specify a URL pointing to an image that is to be used as a background for the document. In most browsers, this background image is used to tile the full background of the document-viewing area. Consider the following code:
<BODY BACKGROUND="imagename.gif">
Rest of the document goes here
</BODY>
It would cause whatever text, images, and so on that appeared in the body of the document to be placed on a background consisting of the imagename.gif graphics file, being tiled to cover the viewing area (like bitmaps are used for Windows wallpaper). Most browsers that support this attribute allow the use of GIF and JPG images for document backgrounds, whereas Internet Explorer supports those, plus Windows BMP files.
The BGCOLOR attribute for <BODY> is not currently in the proposed HTML 3.2 specification, but is supported by Netscape, the Internet Explorer, NCSA Mosaic, and many other browsers and is being considered for inclusion in HTML 3.2. It allows the setting of the color of the background without having to specify a separate image that requires another network access to load. The format is
<BODY BGCOLOR="#rrggbb">
Rest of document goes here
</BODY>
where #rrggbb is a hexadecimal (base 16) red-green-blue triplet used to specify the background color.
Recently, browsers have begun allowing the use of special names to define certain colors. Appendix E, "Colors by Names," presents a list of all the color names recognized by popular browsers and also includes their corresponding hexadecimal triplet values.
Note that using color names is browser specific, so you have greater control over the displayed colors if you use the #rrggbb values instead.
If you change the background colors or patterns within a presentation,
remember to verify that the foreground still looks good on the
new background.
| Color Considerations |
Most graphical browsers allow the downloading of embedded images to be turned off to allow for faster downloading and display of the HTML document. If you turn off downloading for embedded images, background images will not be loaded or displayed. If this happens and no BGCOLOR attribute was specified, all of the foreground text and link-color attributes (TEXT, LINK, VLINK, and ALINK) will be ignored. This is so that documents are not rendered illegibly if the text color scheme authored for use over the set image clashes with the default browser background. |
In Internet Explorer, you can watermark HTML documents by fixing a background image so that it doesn't scroll as a normal background image does. To give a page with a background image a watermarked background, add BGPROPERTIES=FIXED to the <BODY> element as this code shows:
<BODY BACKGROUND="filename.gif" BGPROPERTIES=FIXED>
This Internet Explorer attribute allows you to set the left margin of the document:
<BODY LEFTMARGIN="40">This document is indented 40 pixels from the left hand
edge of the browser window</BODY>
If you set LEFTMARGIN to 0, the page will start at the left-hand side of the page.
These link attributes allow you to control the color of link text. VLINK stands for visited link, and ALINK stands for active link (this sets the color that the link text will be for the time that it is clicked on). Generally, the default colors of these attributes are LINK=blue (#0000FF), VLINK=purple (#800080), and ALINK=red (#FF0000). The format for these attributes is the same as that for BGCOLOR and TEXT:
<BODY LINK="#rrggbb" VLINK="#rrggbb" ALINK="#rrggbb">
Rest of document goes here
</BODY>
You also can use color names rather than hexadecimal values for these attributes. See Appendix E for a complete list of color names and their hexadecimal values.
The TEXT attribute can be used to control the color of all the normal text in the document. This basically consists of all text that is not specially colored to indicate a link. The format of TEXT is the same as that of BGCOLOR:
<BODY TEXT="#rrggbb">
Rest of document goes here
</BODY>
You also can use color names rather than hexadecimal values for these attributes. See Appendix E for a complete list of color names and their hexadecimal values.
This Internet Explorer-specific attribute allows the top margin of the document to be set:
<BODY TOPMARGIN="40">This document is indented 40 pixels from the top hand
edge of the browser window</BODY>
If you set TOPMARGIN to 0, the page will start at the very top of the page.
The <BASE...> element allows you to set the URL of the document itself, to help browsers in situations where the document might be read out of context. It is especially useful in allowing browsers to determine any partial URLs or relative paths that might be specified (for example, in <A HREF> elements or in paths used to specify <IMG SRC=> (images)). The <BASE> element should appear within the bounds of the <HEAD> element only.
Where the base address is not specified, the browser uses the URL it used to access the document to resolve any relative URLs.
The <BASE> element has one standard attribute, HREF, that identifies the URL. The URL should be fully qualified, as in this example:
<BASE HREF="http://www.myhost.com/">
This code specifies www.myhost.com to be the base from which all relative URLs should be determined.
Netscape 2.0 and Internet Explorer 3.0 add one other attribute to the <BASE> element. With the introduction of targeted windows, you can use the TARGET attribute as you use it in anchors (<A>). This allows you to pick a default-named target window for every link in a document that does not have an explicit TARGET attribute. Its format is
<BASE TARGET="default_target">
The <ISINDEX> element tells the browser that the document is an index document. As well as reading it, the reader can use a keyword search.
Readers can query the document with a keyword search by adding
a question mark to the end of the document address, followed by
a list of keywords separated by plus signs.
| Note |
The <ISINDEX> element usually is generated automatically by a server. If added manually to an HTML document, the browser assumes that the server can handle a search on the document. To use the <ISINDEX> element, the server must have a search engine that supports this element. |
Netscape provides the ACTION attribute for the <ISINDEX> element. When used in the <ISINDEX> element, it explicitly specifies the CGI script or program to which the text string in the input box should be passed. For example,
<ISINDEX ACTION="Websearch">
passes the text entered into the input box on the page to the
CGI script Websearch.
| Note |
Websearch in the preceding example is a hypothetical CGI script. The ACTION attribute must point to a properly configured script on the host machine. |
Netscape provides the PROMPT attribute for the <ISINDEX> element. PROMPT allows you to specify text that should be placed before the text-input field of the index. The syntax is
<ISINDEX PROMPT="Any_text_string: ">
where Any_text_string is the text you want to be displayed before the input box.
The <LINK> element indicates a relationship between the document and some other object. A document may have any number of <LINK> elements.
The <LINK> element is empty (it does not have a closing element) but takes the same attributes as the Anchor element (for example, REL, REV, METHODS, TITLE, HREF, and so on).
The <LINK> element typically would be used to provide pointers to related indexes or glossaries. Links also can be used to indicate a static tree structure in which the document was authored by pointing to a parent, next, and previous document, for example.
Servers also may allow links to be added by those who do not have the right to alter the body of a document.
The <LINK> element represents one of the primary style sheet inclusion mechanism elements. It can be used to specify the location of the style sheet that is to be used for the document. For example:
<HTML>
<HEAD>
<TITLE>This HTML document uses a style sheet</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="http://www.stylesheets.com/sheets/formal.css" TITLE="formal">
</HEAD>
<BODY>
Rest of the document goes here
</BODY>
</HTML>
In the preceding HTML fragment, the <LINK> element points to the file formal.css at the given URL. It tells the browser that
| Note |
This HTML fragment represents part of a work in progress specification of the World Wide Web Consortium (W3C). |
For more information about these specific attributes, see the <A> section; for more general information about style sheets, see the style sheets section.
The <NEXTID> element, included in old HTML specifications, is not widely supported and its use is not recommended. Previously, it could be used to provide information about the name of new <A> elements when a document was being edited.
Every HTML document must have a <TITLE> element. As its name suggests, it is used to specify the title of the document in question. Unlike headings, titles typically are not rendered in the text of a document itself. Normally, browsers will render the text contained within the <TITLE>...</TITLE> elements in the title bar of the browser window.
The <TITLE> element
must occur within the head of the document and may not contain
anchors, paragraph elements, or highlighting. Only one title is
allowed in a document.
| Note |
Although the length of the text specified in the <TITLE>...</TITLE> elements is unlimited, for display reasons, most browsers will truncate it. For this reason, title text should be kept short but should be enough to uniquely identify the document. A short title such as Introduction may be meaningless out of context, for example, but if the title were An Introduction to HTML elements, it would be obvious what the document is about. |
This is the only element that is required within the <HEAD> element.
<HEAD>
<TITLE>Welcome to the HTML Reference</TITLE>
</HEAD>
The <META> element is used within the <HEAD> element to embed document metainformation not defined by other HTML elements. Such information can be extracted by servers/clients for use in identifying, indexing, and cataloging specialized document metainformation.
Although it generally is preferable to use named elements that have well-defined semantics for each type of metainformation, such as title, this element is provided for situations where strict SGML parsing is necessary and the local DTD is not extensible.
In addition, HTTP servers can read the content of the document head to generate response headers corresponding to any elements defining a value for the attribute HTTP-EQUIV. This gives document authors a mechanism (not necessarily the preferred one) for identifying information that should be included in the response headers for an HTTP request.
Attributes of the <META> element are listed in the following sections.
The metainformation content to be associated with the given name and/or HTTP response header.
If the document contains
<META HTTP-EQUIV="Expires" CONTENT="Sat, 06 Jan 1990 00:00:01 GMT">
<META HTTP-EQUIV="From" CONTENT="nick@htmlib.com">
<META HTTP-EQUIV="Reply-to" CONTENT="stephen@htmlib.com"
the HTTP response header would be
Expires: Sat, 06 Jan 1990 00:00:01 GMT
From: nick@htmlib.com
Reply-to: stephen@htmlib.com
Commonly, HTML documents can be seen to contain a listing of repeated terms. Some Web search/indexing engines use the keywords information generated from the server or from those specified in the <META HTTP-EQUIV="Keywords" CONTENT="..."> markup to determine the content of the specified document and to calculate their relevance rating (how relevant the document is to the specific search string) for the search results.
When the HTTP-EQUIV attribute is not present, the server should not generate an HTTP response header for this metainformation. For example,
<META NAME="IndexType" CONTENT="Service">
Do not use the <META> element to define information that should be associated with an existing HTML element.
The following is an inappropriate use of the <META> element:
<META NAME="Title" CONTENT="Welcome to the HTML Reference">
Do not name an HTTP-EQUIV equal to a responsive header that typically should be generated only by the HTTP server. Some inappropriate names are Server, Date, and Last-modified. Whether a name is inappropriate depends on the particular server implementation. It is recommended that servers ignore any <META> elements that specify HTTP-equivalents (that are not case sensitive) equal to their own reserved response headers.
The <META> element is particularly useful for constructing dynamic documents via the client pull mechanism. This uses the following syntax:
<META HTTP-EQUIV="Refresh" CONTENT="x">
This causes the browser to believe that the HTTP response when the document was retrieved from the server included the following header:
Refresh: x
It also causes the document to be reloaded in x
seconds.
| Note |
In the preceding example, when the document refreshes, loading itself, the browser will infinitely reload the same document over and over. The only way out of this situation is for the user to activate some hyperlink on the page, load a different document, or click the Back button to reload a previous document. |
This can be useful to provide automatic redirection of browsers. If the element is
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=http://some.site.com/otherfile.html">
the Refresh directive would cause the file at http://some.site.com/otherfile.html to be loaded after two seconds. Although this generally works if the URL specified is partial, you should use a fully qualified URL to ensure its proper functioning.
This attribute binds the element to an HTTP response header. If the semantics of the HTTP response header named by this attribute is known, then the contents can be processed based on a well-defined syntactic mapping whether or not the DTD includes anything about it. HTTP header names are not case sensitive. If not present, the NAME attribute should be used to identify this meta-information, and it should not be used within an HTTP response header.
Metainformation name. If the NAME attribute is not present, the name can be assumed to be equal to the value HTTP-EQUIV.
The anchor text is probably the single most useful HTML element. It is the element that is used to denote hyperlinks-the entire essence of HTML as a hypertext application.
Anchor elements are defined by the <A> element. The <A> element accepts several attributes, but either the NAME or HREF attribute is required.
Attributes of the <A> element are decribed in the following sections.
If the HREF (hypertext reference) attribute is present, the text between the opening and closing anchor elements becomes a hypertext link. If this hypertext is selected by readers, they are moved to another document or to a different location in the current document whose network address is defined by the value of the HREF attribute. Typically, hyperlinks specified using this element would be rendered in underlined blue text, unless the LINK attribute of the <BODY> element has been spe-cified.
In this example, selecting the text HTMLib takes the reader to a document located at http://www.htmlib.com:
See <A HREF="http://www.htmlib.com/">HTMLib</A> for more information about the
HTML Reference.
With the HREF attribute, the form HREF="#identifier" can refer to another anchor in the same document or to a fragment of another document that has been specified using the NAME attribute.
In this example, < and > are character data elements that render as < and >, respectively. In this case, they are used so that <PRE> is actually rendered on-screen (so that the browser doesn't think that the following text is preformatted text).
The <A HREF="document.html#pre"><PRE></A> provides details about the
preformatted text element.
Selecting the link takes the reader to another anchor (that is,
<A NAME="pre"><PRE></A>)
in a different document (document.html).
If the anchor is in another document, the HREF
attribute may be relative to the document's address or the specified
base address, or it can be a fully qualified URL.
| <A HREF="http://..."> | Makes a link to another document located on a World Wide Web server. |
| <A HREF="ftp://..."> | Makes a link to an FTP site. Within an HTML document, normally a connection to an anonymous FTP site would be made. Some browsers, however, allow connections to private FTP sites. In this case, the anchor should take the form ftp://lehunte@htmlib.com and the browser then prompts the user for a password for entry to the site. |
| <A HREF="gopher://...> | Makes a link to a Gopher server. |
| <A HREF="mailto:..."> | Activating such a link brings up the browser's mailing dialog box (if it has mailing capabilities; otherwise, whatever default e-mail software is installed on the system should be activated), allowing the user to send mail messages to
the author of the document, or whoever's address is specified in the mailto: attribute. NCSA Mosaic supports use of the TITLE attribute for the anchor element when used with mailto: links. It allows the author to specify the subject of
the mail message that will be sent. Netscape allows specification of the subject line by using the following syntax:
<A HREF="mailto:lehunte@htmlib.com?subject=The HTML Reference is fantastic"> link text</A> |
| <A HREF="news:..."> | Makes a link to a Usenet newsgroup. Care should be taken in using such links because the author cannot know what newsgroups are carried by the local news server of the user. |
| <A HREF="newsrc:..."> | Makes a link to a specific newsrc file. The newsrc file is used by Usenet news reading software to determine what groups carried by the news server the reader subscribes to. |
| <A HREF="nntp://..."> | Specifies a different news server to that which the user may normally use. |
| <A HREF="telnet://..."> | Activating such a link initiates a Telnet session (using an external application) to the machine specified after the telnet:// label. |
| <A HREF="wais://..."> | Makes a link that connects to a specified WAIS index server. |
The METHODS attributes of anchors and links provide information about the functions the user may perform on an object. These are more accurately given by the HTTP protocol when it is used, but it may be useful to include the information in advance in the link. For example, the browser may chose a different rendering as a function of the methods allowed-something that is searchable may get a different icon or link text display method.
The value of the METHODS attribute is a comma-separated list of HTTP methods supported by the object for public use.
If present, the NAME attribute allows the anchor to be the target of a link. The value of the NAME attribute is an identifier for the anchor, which may be any arbitrary string but must be unique within the HTML document.
<A NAME="pre"><PRE></A> gives information about...
Another document then can make a reference explicitly to this anchor by putting the identifier after the address, separated by a hash sign:
<A HREF="document.html#pre">
The REL attribute gives the relationship(s) described by the hypertext link from the anchor to the target. The value is a comma-separated list of relationship values, which will have been registered by the HTML registration authority. The REL attribute is used only when the HREF attribute is present.
The REV attribute is the same as the REL attribute, but the semantics of the link type are in the reverse direction. A link from A to B with REL="X" expresses the same relationship as a link from B to A with REV="X". An anchor may have both REL and REV attributes.
With the advent of frame page formatting, browser windows now can have names associated with them. Links in any window can refer to another window by name. When you click on the link, the document you asked for appears in that named window. If the window is not already open, Netscape opens and names a new window for you.
The syntax for the targeted windows is
<A HREF="download.html" TARGET="reference">Download information</A>
This loads the document download.html
in the frame that has been designated as having the name reference.
If no frame has this name, Netscape opens a new browser window
to display the document.
| Note |
The use of targeted browser windows is supported by those browsers that currently support the use of <FRAME> page layout (Netscape and Internet Explorer). If the targetted document is part of a frameset, various reserved names can be used to allow smooth window transition. For more information, see <FRAMES>. |
The TITLE attribute is informational only. If present, the TITLE attribute should provide the title of the document whose address is given by the HREF attribute.
This might be useful because it allows the browser to display the title of the document being loaded as retrieval starts-providing information before the new document can be viewed. It is up to individual browsers to specify how they display the title information, but usually it is displayed in the title bar of the browser window. Some documents (such as Gopher or FTP directory listings) do not themselves contain title information within the document. The TITLE attribute can be used to provide a title to such documents. As mentioned earlier, Mosaic supports use of the TITLE attribute to specify the subject of a mail message sent when the user activates a <A HREF="mailto:..."> link.
If present, the URN attribute specifies a uniform resource name (URN) for a target document. The precise specification for URN has not yet been defined, so its use is not recommended.
Block formatting elements are used for the formatting of whole blocks of text within an HTML document (instead of single characters). They should all (if present) be within the body of the document (that is, within the <BODY>...</BODY> elements).
The essential block formatting elements follow:
| <ADDRESS>...</ADDRESS> | Formats an address section |
| <BASEFONT SIZE=...> | Specifies the default font size for the document |
| <BLOCKQUOTE>...</BLOCKQUOTE> | Quotes text from another source |
| <BR> | Forces a line break |
| <CENTER>...</CENTER> | Centers text on the page |
| <COMMENT>...</COMMENT> | Encloses text as a comment |
| <DFN>...</DFN> | Defines an instance |
| <DIV>...</DIV> | Allows centering or left/right justification of text |
| <FONT ...>...</FONT> | Sets/changes the font size, color, and type |
| <HR> | Renders a sizeable hard line on the page |
| <Hx>...</Hx> | Formats six levels of heading |
| <LISTING>...</LISTING> | Formats text |
| <MARQUEE> | Highlights scrolling text |
| <NOBR> | Specifies that words aren't to be broken |
| <P>...</P> | Specifies what text constitutes a paragraph and its alignment |
| <PLAINTEXT> | Formats text |
| <PRE>...</PRE> | Uses text already formatted |
| <WBR> | Specifies that a word is to be broken if necessary |
| <XMP>...</XMP> | Formats text |
As its name suggests, the <ADDRESS>...</ADDRESS> element can be used to denote information such as addresses, authorship credits, and so on.
Typically, an address is rendered in an italic typeface and may be indented, although the actual implementation is at the discretion of the browser. The <ADDRESS> element implies a paragraph break before and after, as shown in this code:
<ADDRESS>
Mr. Cosmic Kumquat<BR>
SSL Trusters Inc.<BR>
1234 Squeamish Ossifrage Road<BR>
Anywhere<BR>
NY 12345<BR>
U.S.A.
</ADDRESS>
Changes the size of the <BASEFONT>, on which all relative <FONT SIZE=+...> changes are based. It defaults to 3 and has a valid range of 1-7.
<BASEFONT SIZE=5>
Changes the face of the HTML document <BASEFONT>,
exactly as it works for <FONT FACE=
...>.
| Note |
This attribute is Internet Explorer specific. |
Allows the <BASEFONT>
color for the HTML document to be set. Colors can be set by using
one of the reserved color names or as an rrggbb
hexadecimal triplet value.
| Note |
The <BASEFONT SIZE=...> element is supported only by Netscape and the Internet Explorer, with the ...FACE and ...COLOR attributes being Internet Explorer specific. This kind of presentation markup also can be specified within a style sheet. |
The <BLOCKQUOTE> element can be used to contain text quoted from another source.
Typically, <BLOCKQUOTE> rendering would be a slight extra left and right indent, and possibly rendered in an italic font. The <BLOCKQUOTE> element causes a paragraph break and provides space above and below the quotation.
In "Hard Drive", a former Microsoft project manager has said,
<BLOCKQUOTE>
"Imagine an extremely smart, billionaire genius who is 14 years old and subject to temper tantrums"
</BLOCKQUOTE>
The line break element specifies that a new line must be started
at the given point. The amount of line space used is dependent
on the particular browser, but is generally the same as it would
use when wrapping a paragraph of text over multiple lines.
| Note |
Some browsers may collapse repeated <BR> elements and render as if only one had been inserted, as shown in this example: <P> |
With the addition of floating images (an embedded image aligned to the left or right of the browser display window, with text flowing around the image), it became necessary to expand the <BR> element. Normal <BR> still just inserts a line break. A CLEAR attribute was added to <BR>, so
CLEAR=left will break the line and move vertically down until you have a clear left margin (where there are no floating images).
CLEAR=right does the same for the right margin.
CLEAR=all moves down until both margins are clear of images.
The CLEAR attribute (as well as floating images) currently are supported only by Netscape and the Internet Explorer.
All lines of text between the begin and end of the <CENTER> element are centered between the current left and right margins. This element was introduced by the Netscape authors because it was claimed that using <P ALIGN=CENTER> "broke" existing browsers when the <P> element was used as a container (that is, with a closing </P> element).
The element is used as shown here, and any block of text (including any other HTML elements) can be enclosed between the centering elements:
<CENTER>All this text would be centered in the page</CENTER>
| Note |
Most browsers will internally work around this element to produce the desired format, but it is an element introduced by Netscape authors. |
The <COMMENT> element can be used to comment out text. As such, it is similar to the <!-- ... --> element.
Any text placed between the <COMMENT> and </COMMENT> elements will not render on-screen, allowing comments to be placed in HTML documents. For example,
<COMMENT>This text won't render. I can say what I like here, it won't appear
</COMMENT>
would not render on-screen.
| Note |
This element is supported only by Internet Explorer and Mosaic. |
Use of the <DFN> element currently is supported only by Internet Explorer.
The <DFN> element can be used to mark the defining instance of a term-for example, the first time some text is mentioned in a paragraph.
Typically, it will render italicized.
The <DFN>Internet Explorer</DFN> is Microsoft's Web browser.
for example, renders as
The Internet Explorer is Microsoft's Web browser.
| Note |
Use of the <DIV> element currently is supported only by Netscape (after version 2.0). |
The <DIV> element, as described in the HTML 3.2 specification, should be used with a CLASS attribute to name a section of text as being of a certain style as specified in a style sheet. Netscape has implemented the <DIV> element to work as the <P ALIGN= ...> element. Essentially, text surrounded by the <DIV>...</DIV> elements is formatted according to the description attached to the ALIGN attribute within the <DIV> elements, as shown in this example:
<DIV ALIGN="left">This text will be displayed left aligned in the browser
window.</DIV>
<DIV ALIGN="center">This text will be centered.</DIV>
<DIV ALIGN="right">This text will be displayed aligned to the right of the
browser window.</DIV>
Netscape 1.0 (and above) and Microsoft's Internet Explorer support different-sized fonts within HTML documents. This should be distinguished from headings.
The element is <FONT SIZE=value>. Valid values range from 1-7. The default FONT size is 3. The value given to SIZE optionally can have a + or - character in front of it to specify that it is relative to the document <BASEFONT>. The default <BASEFONT SIZE= ...> is 3 and is specified with the <BASEFONT SIZE ...> element.
<FONT SIZE=4>changes the font size to 4</FONT>
<FONT SIZE=+2>changes the font size to BASEFONT SIZE ... + 2</FONT>
| Note |
The <FONT SIZE=...> element currently is supported only by Netscape and Internet Explorer. |
Microsoft's Internet Explorer supports the capability to change the font color as well as the typeface. It adds COLOR and FACE attributes to the <FONT> element. Netscape supports the use of the COLOR attribute only.
The COLOR attribute sets the color that text appears on-screen. #rrggbb is a hexadecimal color denoting an RGB color value. Alternatively, the color can be set to one of the available predefined colors. These color names can be used for the BGCOLOR, TEXT, LINK, ALINK, and VLINK attributes of the <BODY> tag as well.
<FONT COLOR="#ff0000">This text is red.</FONT>
or
<FONT COLOR="Red">This text is also red.</FONT>
| Note |
The use of names for coloring text currently is supported only by the Microsoft Internet Explorer and Netscape. Also, it should be noted that HTML attributes of this kind (that format the presentation of the content) also can be controlled via the use of style sheets. |
The FACE attribute sets the typeface used to display the text on-screen. The typeface displayed already must be installed on the user's computer. Substitute typefaces can be specified in case the chosen typeface is not installed on the user's computer. If no exact font match can be found, the text is displayed in the default type that the browser uses for displaying normal text.
<, Comic Sans MS"> This text will be displayed in either Courier New, or Comic Sans MS, depending on which fonts are installed on the browser's system. It will use the default 'normal' font if neither is installed.
</FONT>
| Note |
When using this element, care should be taken to try to use font types that will be installed on the user's computer if you want the text to appear as desired. Changing the font is Internet Explorer specific and also can be set within a style sheet. |
A horizontal rule (<HR>) element is a divider between sections of text, such as a full-width horizontal rule or a similar graphic.
<HR>
<ADDRESS>April 12, 1996, Swansea</ADDRESS>
</BODY>
The <HR> element specifies that a horizontal rule of some sort (the default is a shaded, engraved line) be drawn across the page. It is possible to control the format of the horizontal rule.
Because horizontal rules do not have to be the width of the page, it is necessary to allow the alignment of the rule to be specified. Using these values, rules can be set to display centered, left, or right aligned.
Internet Explorer enables you to specify the hard rule color. Accepted values are any of the Internet Explorer supported color names or any acceptable rrggbb hexadecimal triplet.
For those times when a solid bar is required, the NOSHADE attribute lets you specify that the horizontal rule should not be shaded at all.
The SIZE attribute lets you specify the thickness of the horizontal rule. The number value specifies how thick the rule will be in pixels.
The default horizontal rule is always as wide as the page. With the WIDTH attribute, you can specify an exact width in pixels or a relative width measured in percent of the browser display window.
HTML defines six levels of heading. A heading element implies all the font changes, paragraph breaks before and after, and white space necessary to render the heading.
The highest level of headings is <H1>, followed by <H2>...<H6>.
An example follows:
<H1>This is a first level heading heading</H1>
Here is some normal paragraph text
<H2>This is a second level heading</H2>
Here is some more normal paragraph text.
The rendering of headings is determined by the browser, but typical
renderings (as defined in the HTML 2.0 specification) follow:
| <H1>...</H1> | Bold, very large font, centered. One or two blank lines above and below. |
| <H2>...</H2> | Bold, large font, flush left. One or two blank lines above and below. |
| <H3>...</H3> | Italic, large font, slightly indented from the left margin. One or two blank lines above and below. |
| <H4>...</H4> | Bold, normal font, indented more than H3. One blank line above and below. |
| <H5>...</H5> | Italic, normal font, indented as H4. One blank line above. |
| <H6>...</H6> | Bold, indented same as normal text, more than H5. One blank line above. |
| Note |
These heading alignments can be overridden by using <CENTER> elements or by ALIGNing the heading. |
Although heading levels can be skipped (for example, from H1 to H3), this practice is not recommended because skipping heading levels may produce unpredictable results when generating other representations from HTML. For example, much talked about automatic contents/index generation scripts could use heading settings to generate contents trees where <H2> would be considered to label the start of a section that is a subsection of a section denoted by an <H1> element, and so on.
Included in the HTML 3.2 specification is the capability to align headings.
ALIGN=left|center|right can be added to the <H1> through to <H6> elements. For example,
<H1 ALIGN=center>This is a centered heading</H1>
aligns a heading of style 1 in the center of the page.
| Note |
This element currently is supported only by Mosaic and Netscape. The Internet Explorer supports only the center value, centering the heading. |
The <LISTING> element can be used to present blocks of text in fixed-width font, so it is suitable for text that has been formatted on-screen. As such, it is similar to the <PRE> and <XMP> element but has a different syntax.
Typically, it renders as fixed-width font with white space separating
it from other text. It should be rendered so that 132 characters
fit on the line.
| Note |
Only Netscape actually complies with this. |
The code
Some might say<LISTING>that two heads</LISTING>are better than one
renders as
Some might say
that two heads
are better than one.
| Note |
The Internet Explorer and Netscape translate any special characters included within <LISTING> elements. If characters such as <, >, and so on are used, they are translated to < and >. Mosaic treats the text contained within the elements literally. |
| Note |
This element currently is supported only by Microsoft Internet Explorer. |
The <MARQUEE> element allows you to create a region of text that can be made to scroll across the screen (much like the Windows Marquee screen saver):
<MARQUEE>This text will scroll from left to right slowly</MARQUEE>
This attribute can be set to TOP, MIDDLE, or BOTTOM and specifies that the text around the marquee should align with the top, middle, or bottom of the marquee.
<MARQUEE ALIGN=TOP>Hello in browser land.</MARQUEE>Welcome to this page
The text Welcome to this page
is aligned with the top of the marquee (which scrolls the text
Hello in browser land across
the screen).
| Note |
Until the marquee width is limited by setting the WIDTH attribute, the marquee occupies the whole width of the browser window, and any following text is rendered below the marquee. |
This can be set to SCROLL, SLIDE, or ALTERNATE. It specifies how the text displayed in the marquee should behave. SCROLL (the default) makes the marquee test start completely off one side of the browser window, scroll all the way across and completely off the opposite side, and then start again. SLIDE causes the text to scroll in from one side of the browser window and then stick at the end of its scroll cycle. ALTERNATE means bounce back and forth within the window.
<MARQUEE BEHAVIOR=ALTERNATE>This marquee will "bounce" across the screen</
MARQUEE>
This specifies a background color for the marquee, as an rrggbb hexadecimal triplet or as one of the reserved color names. (See <BODY BGCOLOR> for more information.)
This specifies in which direction the <MARQUEE> text should scroll. The default is LEFT, which means that the text will scroll to the left from the right-hand side of the marquee. This attribute also can be set to RIGHT, which causes the marquee text to scroll from the left to the right.
This specifies the height of the marquee, in pixels (HEIGHT=n) or as a percentage of the screen height (HEIGHT=n%).
This attribute is the same as that for <IMG> (images). It specifies the number of pixels of free space at the left- and right-hand sides of the marquee so that the text that flows around it doesn't push up against the sides.
LOOP=n specifies how many
times a marquee loops when activated. If n=-1
or LOOP=INFINITE is specified,
the marquee action loops indefinitely.
| Note |
If text is enclosed in a <MARQUEE>...</MARQUEE> element set, it defaults to an infinite loop action. |
Specifies the number of pixels between each successive draw of the marquee text-the amount for the text to move between each draw.
SCROLLDELAY specifies the number of milliseconds between each successive draw of the marquee text; it controls the speed at which the text draw takes place.
The following marquee would be extremely fast:
<MARQUEE SCROLLDELAY=1 SCROLLAMOUNT=75>Hello.</MARQUEE>
This attribute is the same as that for <IMG>
(images). It specifies the number of pixels of free space at the
top and bottom edges of the marquee so that the text that flows
around it doesn't push up against the sides.
| Note |
If you want to set the <FONT> to be displayed in the marquee, the <MARQUEE> definition should be enclosed inside the <MARQUEE>, as in this example: |
This specifies the width of the marquee, in pixels (WIDTH=n) or as a percentage of the screen height (WIDTH=n%).
The <NOBR> (no break)
element specifies that all the text between the start and end
of the <NOBR> elements
cannot have line breaks inserted. Although <NOBR>
may be essential for those character sequences that you don't
want to be broken, it should be used carefully; long text strings
inside <NOBR> elements
can look rather odd, especially if the user adjusts the page size
by altering the window size.
| Note |
The <NOBR> element is supported only by Netscape and Internet Explorer. |
The paragraph element indicates a paragraph of text. No specification has ever attempted to define exactly the indentation of paragraph blocks, and this may be a function of other elements, style sheets, and so on.
Typically, paragraphs should be surrounded by a vertical space of between one and one-and-a-half lines. With some browsers, the first line in a paragraph may be indented.
<H1>The Paragraph element</H1>
<P>The paragraph element is used to denote paragraph blocks.</P>
<P>This would be the second paragraph.</P>
Included in the HTML 3.2 specification is the capability to align paragraphs.
Basically, the ALIGN=left|center|right attribute and values have been added to the <P> element.
In the following example, all text within the paragraph will be aligned to the left side of the page layout. This setting is equal to the default <P> element:
<P ALIGN=LEFT> ... </P>
In this example, all text within the paragraph is aligned to the center of the page. (See also <CENTER>...</CENTER>.)
<P ALIGN=CENTER> ... </P>
In this example, all text is aligned to the right side of the page.
<P ALIGN=RIGHT> ... </P>
| Note |
Internet Explorer supports only the use of the left and center values, whereas Mosaic and Netscape support the use of all three values. |
The <PLAINTEXT> element can be used to represent formatted text. As such, it is similar to the <XMP> and <LISTING> element. However, the <PLAINTEXT> element should be an open element, with no closing element. Only Netscape supports this element according to any HTML specification. Internet Explorer and Mosaic will allow the use of a </PLAINTEXT> closing element. Netscape treats the closing element literally and displays it.
Typically, it renders as fixed-width font with white space separating it from other text.
I live<PLAINTEXT>in the rainiest part of the world.
renders as
I live
in the rainiest part of the world.
Anything following the opening <PLAINTEXT> element should be treated as text. Only Netscape behaves like this. Internet Explorer and Mosaic allow the use of a closing </PLAINTEXT> element, allowing discrete blocks of <PLAINTEXT> formatted text to be displayed.
The preformatted text element presents blocks of text in fixed-width font and is suitable for text that has been formatted on-screen or in a monospaced font.
The <PRE> element may be used with the optional WIDTH attribute, which is an HTML Level 1 feature. The WIDTH attribute specifies the maximum number of characters for a line and allows the browser to determine which of its available fonts to use and how to indent the text (if at all). If the WIDTH attribute is not present, a width of 80 characters is assumed. Where the WIDTH attribute is supported, widths of 40, 80, and 132 characters should be presented optimally, with other widths being rounded up.
Within preformatted text, any line breaks within the text are
rendered as a move to the beginning of the next line. The <P>
element should not be used, but if it is found, it should be rendered
as a move to the beginning of the next line. It is possible to
use anchor elements, and character highlighting elements are allowed.
Elements that define paragraph formatting (headings, address,
and so on) must not be used. The horizontal tab character (encoded
in US-ASCII and ISO-8859-1 as decimal 9) represents a special
formatting case. It should be interpreted as the smallest positive
nonzero number of spaces that will leave the number of characters
so far on the line as a multiple of 8. (However, despite being
allowed, its use is not recommended.)
| Note |
It is at the discretion of individual browsers how to render preformatted text. Where "beginning of a new line" is implied, the browser can render that new line indented if it sees fit. For example, <PRE WIDTH="80"> Within a preformatted text element, the constraint that the rendering must be on a fixed horizontal character pitch may limit or prevent the capability of the browser to render highlighting elements specially. |
The <WBR> element (word
break) is for the very rare case when a <NOBR>
section requires an exact break. Also, it can be used any time
the browser can be helped by telling it where a word is allowed
to be broken. The <WBR>
element does not force a line break (<BR>
does that); it simply lets the browser know where a line break
is allowed to be inserted if needed.
| Note |
<WBR> is supported only by Netscape and the Internet Explorer. |
The <XMP> element can be used to present blocks of text in fixed-width font and is suitable for text that has been formatted on-screen. As such, it is similar to the <PRE> and <LISTING> elements but has a different syntax.
Typically, it renders as fixed-width font with white space separating it from other text. It should be rendered so that 80 characters fit on the line. For example,
The <XMP>Netscape Navigator</XMP>supports colored tables.
renders as
The
Netscape Navigator
doesn't support colored tables.
| Note |
The Internet Explorer translates any special characters included within <XMP> elements. If characters such as <, >, and so on are used, they are translated to < and >. Netscape and Mosaic treat the text contained within the elements literally. |
Within an HTML document, any characters between the HTML elements represent text. An HTML document (including elements and text) is encoded by means of a special character set described by the charset parameter as specified in the text/html MIME type. Essentially, this is restricted to a character set known as US-ASCII (or ISO-8859-1), which encodes the set of characters known asLatin Alphabet No 1 (commonly abbreviated to Latin-1). This covers the characters from most Western European languages. It also covers 25 control characters, a soft hyphen indicator, 93 graphical characters, and 8 unassigned characters.
It should be noted that non-breaking space and soft hyphen indicator characters are not recognized and interpreted by all browsers; because of this, their use is discouraged.
There are 58 character positions occupied by control characters. See "Control Characters" for details on the interpretation of control characters.
Because certain special characters are subject to interpretation and special processing, information providers and browser implementers should follow the guidelines in the "Special Characters" section.
In addition, HTML provides character-entity references and numerical character references to facilitate the entry and interpretation of characters by name and by numerical position.
Because certain characters are interpreted as markup, they must be represented by entity references as described in "Character and/or Numerical References."
Many of the Latin-1 set of printing characters may be represented within the text of an HTML document by a character entity.
It may be beneficial to use character entity references instead of directly typing the required characters as described in the numerical entity references; this enables you to compensate for keyboards that don't contain the required characters (such as characters common in many European languages) and for characters that may be recognized as SGML coding.
A character entity is represented in an HTML document as an SGML entity whose name is defined in the HTML DTD. The HTML DTD includes a character entity for each of the SGML markup characters and for each of the printing characters in the upper half of Latin-1, so you can reference them by name if it is inconvenient to enter them directly:
the ampersand (&), double quotation marks ("), lesser (<) and greater (>) characters
Kurt Gödel was a famous logician and mathematician.
| Note |
To ensure that a string of characters is not interpreted as markup, represent all occurrences of <, >, and & by character or entity references. |
Table B.2 contains the possible numeric and character entities
for the ISO-Latin-1 (ISO8859-1) character set. Where possible,
the character is shown.
| Note |
Not all browsers can display all characters, and some browsers may even display characters different from those that appear in the table. Newer browsers seem to have a better track record for handling character entities, but be sure to test your HTML files extensively with multiple browsers if you intend to use these entities. |
| Unused | ||||
| Horizontal tab | ||||
| Line feed | ||||
| Unused | ||||
| Space | ||||
| Exclamation mark | ||||
| Quotation mark | ||||
| Number sign | ||||
| Dollar sign | ||||
| Percent sign | ||||
| Ampersand | ||||
| Apostrophe | ||||
| Left parenthesis | ||||
| Right parenthesis | ||||
| Asterisk | ||||
| Plus sign | ||||
| Comma | ||||
| Hyphen | ||||
| Period (fullstop) | ||||
| Solidus (slash) | ||||
| Digits 0-9 | ||||
| Colon | ||||
| Semicolon | ||||
| Less than | ||||
| Equal sign | ||||
| Greater than | ||||
| Question mark | ||||
| Commercial at | ||||
| Letters A-Z | ||||
| Left square bracket | ||||
| Reverse solidus (backslash) | ||||
| Right square bracket | ||||
| Caret | ||||
| Horizontal bar | ||||
| Grave accent | ||||
| Letters a-z | ||||
| Left curly brace | ||||
| Vertical bar | ||||
| Right curly brace | ||||
| Tilde | ||||
| Unused | ||||
| Inverted Exclamation point | ||||
| Cent sign | ||||
| Pound sterling | ||||
| General currency sign | ||||
| Yen sign | ||||
| Broken vertical bar | ||||
| Section sign | ||||
| Umlaut (dieresis) | ||||
| Copyright | ||||
| Feminine ordinal | ||||
| Left angle quotation, guillemot left | ||||
| Not sign | ||||
| Soft hyphen | ||||
| Registered trademark | ||||
| Macron accent | ||||
| Degree sign | ||||
| Plus or minus | ||||
| Superscript two | ||||
| Superscript three | ||||
| Acute accent | ||||
| Micro sign | ||||
| Paragraph sign | ||||
| Middle dot | ||||
| Cedilla | ||||
| Superscript one | ||||
| Masculine ordinal | ||||
| Right angle quota- tion, guillemot right | ||||
| Fraction one-fourth | ||||
| Fraction one-half | ||||
| Fraction three- fourths | ||||
| Inverted question mark | ||||
| Capital A, grave accent | ||||
| Capital A, acute accent | ||||
| Capital A, circumflex accent | ||||
| Capital A, tilde | ||||
| Capital A, dieresis or umlaut mark | ||||
| Capital A, ring | ||||
| Capital AE dipthong (ligature) | ||||
| Capital C, cedilla | ||||
| Capital E, grave accent | ||||
| Capital E, acute accent | ||||
| Capital E, circumflex accent | ||||
| Capital E, dieresis or umlaut mark | ||||
| Capital I, grave accent | ||||
| Capital I, acute accent | ||||
| Capital I, circumflex accent | ||||
| Capital I, dieresis or umlaut mark | ||||
| Capital Eth, Icelandic | ||||
| Capital N, tilde | ||||
| Capital O, grave accent | ||||
| Capital O, acute accent | ||||
| Capital O, circumflex accent | ||||
| Capital O, tilde | ||||
| Capital O, dieresis, or umlaut mark | ||||
| Multiply sign | ||||
| Capital O, slash | ||||
| Capital U, grave accent | ||||
| Capital U, acute accent | ||||
| Capital U, circumflex accent | ||||
| Capital U, dieresis or umlaut mark | ||||
| Capital Y, acute accent | ||||
| Capital THORN, Icelandic | ||||
| Small sharp s, German (sz ligature) | ||||
| Small a, grave accent | ||||
| Small a, acute accent | ||||
| Small a, circumflex accent | ||||
| Small a, tilde | ||||
| Small a, dieresis or umlaut mark | ||||
| Small a, ring | ||||
| Small ae dipthong (ligature) | ||||
| Small c, cedilla | ||||
| Small e, grave accent | ||||
| Small e, acute accent | ||||
| Small e, circumflex accent | ||||
| Small e, dieresis or umlaut mark | ||||
| Small i, grave accent | ||||
| Small i, acute accent | ||||
| Small i, circumflex accent | ||||
| Small i, dieresis or umlaut mark | ||||
| Small eth, Icelandic | ||||
| Small n, tilde | ||||
| Small o, grave accent | ||||
| Small o, acute accent | ||||
| Small o, circumflex accent | ||||
| Small o, tilde | ||||
| Small o, dieresis or umlaut mark | ||||
| Division sign | ||||
| Small o, slash | ||||
| Small u, grave accent | ||||
| Small u, acute accent | ||||
| Small u, circumflex accent | ||||
| Small u, dieresis or umlaut mark | ||||
| Small y, acute accent | ||||
| Small thorn, Icelandic | ||||
| Small y, dieresis or umlaut mark |
Control characters are non-printable characters that typically are used for communication and device control, as format effectors, and as information separators.
In SGML applications, the use of control characters is limited in order to maximize the chance of successful interchange over heterogenous networks and operating systems. In HTML, only three control characters are used: horizontal tab (HT, encoded as 9 decimal in US-ASCII and ISO-8859-1), carriage return, and line feed.
A horizontal tab is interpreted as a word space in all contexts except preformatted text. Within preformatted text, the tab should be interpreted to shift the horizontal column position to the next position that is a multiple of 8 on the same line; that is, col := ((col+8) div8) * 8 (where div is integer division).
Carriage returns and line feeds conventionally are used to represent the end of a line. For Internet Media Types defined as text/*, the sequence CR/LF is used to represent the end of a line. In practice, text/html documents frequently are represented and transmitted using an end-of-line convention that depends on the conventions of the source of the document; frequently, that representation consists of CR only, LF only, or a CR/LF combination. In HTML, the end of line in any of its variations is interpreted as a word space in all contexts except preformatted text. Within preformatted text, HTML interpreting agents should expect to treat any of the three common representations of end of line as starting a new line.
In addition to any mechanism by which characters may be represented by the encoding of the HTML document, it is possible to explicitly reference the printing characters of the Latin-1 character encoding using a numeric character reference.
There are two principal cases for using a numeric character reference. First, some keyboards may not provide the necessary characters (such as those that use accents, cedillas, dieresis marks, and so on) commonly used in European languages. Second, some characters would be interpreted as SGML coding (for example, the ampersand (&), quotation marks (" "), less than sign (<), and greater than sign (>) characters) and therefore should be referred to by numerical references.
Numeric character references are represented in an HTML document
as SGML entities in which the name is a number sign (#) followed
by a numeral from 32-126 and 161-255. The HTML DTD includes a
numeric character for each of the printing characters of the
Latin-1 encoding, so you can reference them by number if it is
inconvenient to enter them directly: the ampersand (&),
quotation marks ("),
lesser (<) and greater
(>) char-acters.
The following entity names are used in HTML, always prefixed by ampersand (&) and followed by a semicolon (see Table B.1).
Certain characters have special meanings in HTML documents. There are two printing characters that may be interpreted by an HTML application to have an effect of the format of the text.
This is interpreted as a single word space (the section of a paragraph of text where the text can be broken if necessary-for example, where lines can be broken for text wrapping) except when it is used within <PRE>...</PRE> elements. Within preformatted text elements, a space is interpreted as a nonbreaking space.
This is interpreted as a hyphen glyph in all contexts.
The following entity names are used in HTML, always prefixed by
ampersand (&) and followed
by a semicolon (;). They
represent particular graphics characters that have special meanings
in places in the markup or may not be part of the character set
available to the writer.
| Description | |||
| Less than sign | |||
| Greater than sign | |||
| Ampersand | |||
| Quotation mark |
| Note |
Two different elements now exist for employing inline sound directly in an HTML document. The first is BGSOUND; this element currently is supported only by Microsoft Internet Explorer. The other is SOUND, which currently is supported only by NCSA Mosaic. Mosaic also supports a limited version of Microsoft's BGSOUND element. Netscape can support inline sound via the plugin mechanism. See <EMBED> for more details. |
The BGSOUND element allows you to create pages that play sound clips or background soundtracks while the page is being viewed. Sounds can be samples (.WAV or .AU) or MIDI (.MID) format.
The HTML used to insert a background sound into a page is
<BGSOUND SRC="start.wav">
The BGSOUND element accepts the following attributes.
Specifies the address of a sound to be played.
Specifies how many times a sound loops when activated. If n=-1 or LOOP=INFINITE is specified, the sound loops indefinitely.
Mosaic supports use of the SOUND
element for playing inline sound. This element allows the playing
of *.WAV files in pages.
| Note |
The SOUND element is supported only by Mosaic. |
The syntax is
<SOUND SRC="filename.wav">
The <SOUND> element supports the following attributes:
LOOP=infinite and DELAY=sec
LOOP=infinite plays the sound sample continuously while the page is being viewed.
DELAY=sec delays playing
of the sound file for sec
seconds after the page and sound file finish loading.
| Note |
Although Mosaic supports the use of the BGSOUND element (for .WAV file), it does not play inline *.MID MIDI files without launching an external application as defined in the Helper Application setup. |
Recent advances in browser technology have been pushing the idea of active content. To this end, you should be aware of a few HTML methods:
Server push This mechanism generally has been used for providing animation within Web pages, whereby the Web server serves the page that the browser has requested and keeps the client (browser) to server connection open and repeatedly sends chunks of data as long as the connection is kept open. To be able to take advantage of such a mechanism requires an in-depth knowledge of MIME types, the HTTP transport protocol, and CGI scripting or programming. It therefore is recommended only for programmers.
Client pull As seen in the discussion of the <META> element, this method provides a useful automatic redirection mechanism for serving Web pages. The server serves the browser the requested page (which contains metainformation) which makes the browser believe that it has received certain HTTP response headers, which typically would be used to make the browser retrieve a different document. For more details, see the <META> element.
Server push allows for dynamic document updating via a server-to-client connection that is kept open. This method (as opposed to client pull) is totally controlled by the server, but the perpetual open connection occupies valuable server resources. Its main advantage over client pull is that you can use server push to replace a single inline image in a page repeatedly. All that is needed is that the SRC attribute of the image to be updated points to a URL that continually pushes image data through the open HTTP connection.
The exact server push mechanism is technically complex and is outside the scope of this reference. This section presents a brief outline of the method. Those interested in utilizing server push in CGI scripts or Web server-based executable applications should visit the Netscape Web site (http://home.netscape.com/) for more information. It should be noted that only Netscape supports the use of server push.
When a Web server receives a request for an HTML document to be retrieved, it typically sends a single set of data (the actual HTML document). MIME possesses a facility whereby many pieces of data can be sent encapsulated in a single message by using the MIME type multipart/mixed where the message is split into separate data sections, each provided with their own MIME type (given in the content header) so that the browser can distinguish between the different data in the different sections of the message. Server push uses a variation on this MIME type, called multipart/x-mixed-replace (the x- represents the fact that the MIME type is experimental and has not achieved standardized use). It is by virtue of the replace section that certain sections of the message can be replaced. Essentially, the server does not push down the entire message at once. It sends down sections (data chunks) of the message when it sees fit (or as controlled by the server push script or application). When the browser sees a separator (sent down in the multipart/x-mixed-replace message), it just sits and waits for the next data object to be sent, which it then uses to replace the data previously sent by the server.
Perhaps the biggest advance the HTML 2.0 specification made over its predecessors was the inclusion of elements that allowed for users to input information. These elements are the <FORM> elements. They provide for the inclusion of objects like text boxes, choice lists, and so on, and have proved invaluable for recent HTML applications-particularly, search engines, database query entry, and so on.
It should be noted that although these HTML elements can be used to easily define the presentation of the form to the user, the real value behind any form is in what it does with the information that is entered. For a form to do anything more than send a straight text dump of the form data (including control characters) to an e-mail address, the form data will need to be passed to some kind of CGI script or server-based executable for processing.
The following elements are used to create forms:
| <FORM>...</FORM> | A form within a document |
| <INPUT ...>...</INPUT> | One input field |
| <OPTION> | One option within a Select element |
| <SELECT>...<SELECT> | A selection from a finite set of options |
| <TEXTAREA ...>...</TEXTAREA> | A multi-line input field |
Each variable field is defined by an INPUT, TEXTAREA, or OPTION element and must have a NAME attribute to identify its value in the data returned when the form is submitted.
A very simple form for eliciting user response follows, and its output is shown in Figure B.1.
<H1 ALIGN="center">Comment Form</H1>
<FORM METHOD="POST" ACTION="http://www.htmlib.com/formscript.cgi">
<CENTER>
Your name: <INPUT NAME="name" size="20">
Your e-mail address: <INPUT NAME="email" size="20">
<P>I think the HTML Reference is:
<SELECT NAME="Choice">
<OPTION>Outstanding
<OPTION>Very good
<OPTION>Good
<OPTION>Average
<OPTION>Below Average
<OPTION>Awful
<OPTION SELECTED>My response would be "indecent" under the CDA Act.
</SELECT>
<P>If you have any further comments, please enter them here:<BR>
<TEXTAREA NAME="Comments" ROWS="10" COLS="40" WRAP="Virtual">
</TEXTAREA>
<P><INPUT TYPE=SUBMIT> <INPUT TYPE=RESET>
</CENTER>
</FORM>
Different platforms will have different native systems for navigating within the input fields of a form. (For example,Windows users can use the Tab key to move from one field to the next through the order that the fields appear within the form.) Different browsers also may display different text on any buttons included in the form. For example, Netscape defaults to displaying Submit Query for a button specified by <INPUT TYPE=SUBMIT>, whereas the Internet Explorer and Mosaic display just Submit on such a button.
It is possible to write forms that ask for files as input, rather than data input by input boxes and other simple elements such as check boxes and radio buttons.
An example of such a form follows:
<FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
Send this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File">
</FORM>
| Note |
This method of file upload is Netscape specific and is essentially adoption of another IETF Internet Draft by the Netscape authors. The Internet Draft in question, "Form based file upload in HTML," details adding the FILE option to the TYPE attribute of the INPUT element, allowing an ACCEPT attribute for the INPUT element (which would be a list of MIME types-essentially detailing what files are allowed to be uploaded as the contents of the form) and allowing the ENCTYPE of a form to be multipart/form-data. This MIME type essentially wraps the form data (including that presented in any other input fields) as a data stream, with discrete boundaries between the information sections. For a more detailed description, readers should check the HTTP file upload specification. |
The display method is largely at the discretion of the browsers that support this method. Netscape (Windows versions) displays a Browse button beside the input box, which brings up the standard Open/Save dialog box, allowing the choice of any local file for upload.
The <FORM> element is used to delimit a data input form. There can be several forms in a single document, but the <FORM> element cannot be nested. (A form can't contain another form.)
<FORM ACTION="_URL_" METHOD="GET|POST" ENCTYPE="MIME type">
The ACTION attribute is a URL specifying the location to which the contents of the form data fields are submitted to elicit a response. As mentioned before, this could be simply a direction to an e-mail address, but generally it is used to point toward some kind of server-based CGI script/application that handles the forwarding of form data. If the ACTION attribute is missing, the URL of the document itself is assumed. The way data is submitted varies with the access protocol of the URL to which the form data is sent and with the values of the METHOD and ENCTYPE attributes.
Generally, the METHOD attribute specifies a method of accessing the URL specified in the ACTION atbute. Generally, the method is GET or POST. The GET method is ideal for form submission where the use of the form data does not require external processing. With database searches, for example, there is no lasting effect caused by the query of the form (the query runs its search through the database and reports the results). However, when the form is used to provide information that updates a database, the POST method should be used, with the ACTION attribute pointing to a CGI script that executes the form data processing.
The ENCTYPE specifies the media type used to encode the form data. The default ENCTYPE is the MIME type application/x-www-form-urlencoded.
The <INPUT> element represents a field whose contents may be edited or activated by the user.
Attributes of the <INPUT> element follow.
To be used with the TYPE=IMAGE setting, this attribute specifies the alignment of the image. It takes the same values as the ALIGN in the <IMG> element.
To be used with a TYPE=CHECKBOX or TYPE=RADIO setting, this indicates that the check box or radio button is selected.
To be used with TYPE=TEXT setting, this indicates the maximum number of characters that can be entered into a text field. This can be greater than specified by the SIZE attribute, in which case the field scrolls appropriately. The default number of characters is unlimited.
Represents the name that will be used for the data when transferring the form's contents. The NAME attribute is required for most input types and normally is used to provide a unique identifier for a field or a logically related group of fields.
Specifies the size or precision of the field according to its type. For example, to specify a field with a visible width of 24 characters, use this code:
INPUT TYPE=text SIZE="24"
To be used with the TYPE=IMAGE, represents a URL specifying the desired image.
Defines the type of data the field accepts. Defaults to free text. Several types of fields can be defined with the type attribute:
| Note |
In a future version of the HTML specification, the IMAGE functionality may be folded |