Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

JavaScript Manual of Style

Appendix C -- A Review of HTML

Appendix C

A Review of HTML


CONTENTS



Bore you can use JavaScript in a Web page, you need to know how to write a Web page. This appendix reviews the basic HTML you need to know to put together Web pages. It also reviews the structure of a good Web page.

The basic structure of a Web page

Web pages are composed of HTML tags, content, and comments. The content-the plain text of the page-should be contained within HTML tags. Most browsers will display content that is not contained within HTML tags, but HTML standards don't require them to display uncontained content.

The content, not the tags, should contain comments, if for no better reason than that it makes the page more readable and easier to maintain. Comments begin with <!-- and end with -->. It's a good practice never to place a double dash (--) or a right angle bracket (>) within a comment. Some browsers may prematurely terminate the comment when they read these character sequences. It's important to remember this when writing JavaScript code, which you usually place inside comments to keep JavaScript-ignorant browsers from displaying the code on the screen.

HTML tags are special keywords enclosed within angle brackets (< and >). They may have attributes that refine the behavior of the tag; attributes are typically of the form name=value. When a tag has attributes, some of them are mandatory and the others are optional. Certain browsers may let you get away with omitting mandatory attributes, but you shouldn't expect all browsers to do so. The attribute values may be numeric or text, and may be enclosed within quotes. Some tools you can use to verify the syntax of your pages have trouble with attribute values; enclosing the values within quotes usually helps.

Tag and attribute names are case-insensitive. Attribute values are almost always case-sensitive. Because most content is lowercase (uppercase text is perceived as shouting), I prefer to write tag and attribute names in uppercase. It makes them stand out from the content.

Most tags have corresponding end tags. The end tag contains the same keyword as the first tag, or start tag, but with a leading slash (/) character. Like the start tag, it is enclosed within angle brackets. Unlike start tags, end tags do not have attributes.

Some tags contain text, and these tags have end tags. In certain specialized circumstances, the end tag is implied; for example, within a table row, a table cell that starts with a <TD> tag is implicitly ended by another <TD> tag. It is a good practice, however, always to use end tags. It makes your code easier to read and maintain.

An HTML element consists of either a tag that contains no text, such as an <IMG> tag, or a tag and its end tag and the text between them, such as

<B>Some bold text</B>

In the first case, the element is called an empty element. In the second case, the element is called a container element.

Certain rules dictate which HTML elements can exist within which other HTML elements. You can nest HTML elements, but their start and end tags cannot overlap. For example, you may wish to render text in a bold italic font. You can do so by enclosing the text within <B> and </B>, and within <I> and </I>. <B><I>text</I></B> will work. <I><B>text</B></I> will work. <B><I>text</B></I> will not work.

Some tags have attributes in common with each other. These common attributes take common values, and these values may not be very obvious as to what they do. Uniform Resource Locators, colors, the ALIGN attribute, and the CLEAR attribute are not well understood.

Uniform Resource Locators

Uniform Resource Locators, or URLs, specify the location of documents on the Internet, and the protocol that is used to retrieve them. The general format of a URL is

protocol hostname port pathname search hash

These are defined as follows:

protocolThe beginning of a URL, up to the first colon. Common protocols include javascript: (JavaScript code), about: (navigator information), http: (World Wide Web), file: (local file), ftp: (FTP), mailto: (mail), news: (Usenet news), and gopher: (Gopher). The protocol may be separated from the rest of the URL by two slashes (http:, ftp:, news:), three slashes (file:), or no slashes (javascript:, about:, mailto:, gopher:).
hostnameThe host and domain name, or IP address, of a network host.
portThe number of the communications port used by the network host for communication. Many protocols define a "well-known" port number (21 for FTP, 70 for Gopher, 80 for the World Wide Web, 119 for Usenet news, to name a few) for the protocol, and because most hosts use the well-known port numbers, the port component is rarely used.
pathnameThe path of the file, including the file name, on the network host.
searchQuery information, beginning with a question mark.
hashAn anchor name, beginning with a hash mark (#)

An absolute URL has a protocol, host name, and path name, and may include a port, search, and hash field.

A relative URL has no protocol or host name, and the path name is not usually a full path name.

Colors

Tags that take color attributes may specify the color values in two different ways: by name or by hex triplet.

There are 140 defined color names, such as red, black, and turquoise. For a complete list of these defined colors, check the code listings for Chapter 6

Hex triplets consist of a pound sign followed by the hexadecimal values of the red component, the green component, and the blue component. Each component may have a value from 00 to FF, and must have two digits.

Alignment

Some elements can float freely within a stream of text, and have ALIGN attributes that permit you to dictate where the element will appear on the screen. The most common values for the ALIGN attribute are left, right, top, texttop, middle, absmiddle, baseline, bottom, and absbottom.

Left and right alignment (ALIGN="left" and ALIGN="right") place a free-floating element below the current line of text, on either the left margin or the right margin. Text flows around the element.

Top and texttop alignment (ALIGN="top" and ALIGN="texttop") place a free-floating element on the screen so that the top of the element is lined up with the top of the line up to that point. In other words, alignment is with respect to text and elements to the left of the current element. The difference between top and texttop alignment is that top alignment takes text and elements into account, and texttop alignment only considers text.

Middle and absmiddle alignment (ALIGN="middle" and ALIGN="absmiddle") place a free-floating element on the screen so that the middle of the element is lined up with either the baseline of the text (ALIGN="middle") or with the middle of the text and elements to the left (ALIGN="absmiddle"). When there is nothing but text to the left, there is almost no difference between the two.

Baseline, bottom, and absbottom alignment (ALIGN="baseline", ALIGN="bottom", and ALIGN="absbottom") place a free-floating element on the screen so that the bottom of the element is lined up either with the baseline of the text (ALIGN="baseline" and ALIGN="bottom"-they are synonymous) or with the bottom of the lowest text or element to the left of the free-floating element (ALIGN="absbottom").

Clear

CLEAR is a common attribute used by elements. This attribute specifies that the browser should go farther down the screen until the specified margin is clear before displaying the element's text. Typical values are left, right, and all (both left and right margins must be clear).

In Figures C.1 through C.4, a BR (line break) element, which can take a CLEAR attribute, is inserted into the text following the word "break." In Figure C.1, with CLEAR="left", the text stops until the image on the left is cleared, and then resumes. In Figure C.2, with CLEAR="right", the text stops until the image on the right is cleared, and then resumes. In Figure C.3, with CLEAR="all", the text stops until both images are cleared, and then resumes. Finally, in Figure C.4, there is no CLEAR attribute and text resumes on the next line, between the two images.

Figure C.1 : <BR CLEAR="left">.

Figure C.2 : <BR CLEAR="right">.

Netscape-supported HTML elements

This section includes short descriptions of the HTML elements currently supported by Netscape. These elements do not pertain solely to JavaScript. Each element description mentions commonly used attributes of the element, explains the function of the element, includes special notes about the element, and tells what elements may be contained within that element.

Figure C.3 : <BR CLEAR="all">.

Figure C.4 : <BR> with no CLEAR attribute.

The A element marks the beginning of a hypertext link if it uses the HREF attribute or the destination of a hypertext link if it uses the NAME attribute. In JavaScript, it's a link object if it uses the HREF attribute and an anchor object if it contains the NAME attribute. There are five attributes, but an A element must have an HREF or NAME attribute. Both can be used in the same element-an A element may be both a link object and an anchor object.

HREF=stringThe value specifies the target of a hypertext link.
NAME=stringThe value creates a destination for a hypertext link.
ONCLICK=stringThe value specifies a JavaScript expression to be executed when the user clicks on the element. This only applies to A elements that have an HREF attribute defined.
ONMOUSEOVER=
string
The value specifies a JavaScript expression to be executed when the user moves the mouse pointer over the element. This only applies to A elements that have an HREF attribute defined.
TARGET=stringThe value specifies a window or frame into which the link will be loaded. This only applies to A elements that have an HREF attribute defined.

The A element is a container element that can contain content text and B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, H1, H2, H3, H4, H5, H6, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, SUB, SUP, TT, VAR, and WBR elements. It may not contain another A element. Its contents are usually highlighted by the browser when the HREF attribute is used.

ADDRESS

The ADDRESS element indicates that its contents constitute an address. Typical usage would include electronic signatures and lists of authors. This element has no attributes, and it is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, P, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

APPLET

The APPLET element loads a Java applet and executes it. It has eight attributes:

ALIGN=stringThe value specifies the applet's alignment on the page. Permitted values include left, right, top, texttop, middle, absmiddle, baseline, bottom, and absbottom.
CODE=stringThe value specifies the relative URL of the applet. This attribute is mandatory.
CODEBASE=stringThe value specifies a base URL for the CODE attribute's relative URL. In the absence of this attribute, the document URL becomes the base URL.
HEIGHT=numberThe value specifies the height, in pixels, of the applet. This attribute is mandatory.
HSPACE=numberThe value specifies the horizontal distance, in pixels, between the applet and surrounding text.
NAME=stringThe value creates a destination for a hypertext link.
VSPACE=numberThe value specifies the vertical distance, in pixels, between the applet and surrounding text.
WIDTH=numberThe value specifies the width, in pixels, of the applet. This attribute is mandatory.

The APPLET element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, PARAM, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, VAR, and WBR elements.

AREA

The AREA element defines a region within a MAP element that the user may select. If the HREF attribute is used, the area acts like the beginning of a hypertext link. If the NOHREF attribute is used, the area acts like a "dead zone"; if the user clicks in such an area, nothing happens. There can be multiple AREA elements within a MAP element. In case of overlap, the first AREA element that contains the coordinates the user selected will be the active element. The coordinates start in the image's upper-left corner.

There are four attributes:

COORDS=stringThe value specifies the coordinates that define the area.

If the area is a rectangle, there are four coordinates: left, top, right, and bottom. If the area is a circle, there are three coordinates: the center of the circle (horizontal coordinate and then vertical coordinate) followed by the radius. If the area is a polygon, there are an arbitrary number of coordinate pairs. In this case, each pair describes a vertex of the polygon. The vertex's horizontal coordinate is first, followed by the vertical coordinate. The last pair does not need to match the first pair; in that case, the browser will assume a line segment between the first vertex and the last vertex.

HREF=stringThe value identifies a hypertext link that will be the target if a point within this area's coordinates is selected.
NOHREFThis attribute means that this area describes a dead zone; nothing will happen if you select a point within this area's coordinates.
SHAPE=stringThe value specifies the shape of the area. Valid values include circle, rect (rectangle), and poly (polygon). The default shape is a rectangle.

The AREA element is an empty element.

B (Boldface)

The B element specifies that the browser should render the contents in a bold font.

There are no attributes. The B element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

BASE

The BASE element overrides the Web page's URL as the base for relative URLs. It has one mandatory attribute, HREF=string, where the value specifies the base for relative URLs.

The BASE element is empty.

BASEFONT

The BASEFONT element overrides the value of the base font size (which by default is 3). The browser adds relative FONT element values to the base font size. The BASEFONT element has one mandatory attribute, SIZE=number, where the number value is the base font size.

The BASEFONT element is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

BIG

The BIG element specifies that the browser should render the contents in a larger than normal font.

There are no attributes. The BIG element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

BLINK

The BLINK element requests that contained elements be rendered in a blinking font. The blinking effect is as alarming as a shout of "Fire!" Just as most of us don't have a reason to pull the fire alarm every day, there is hardly ever a good reason to include blinking text in an ordinary document. Use of BLINK is considered even more vulgar than writing text in all uppercase.

There are no attributes. The BLINK element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

BLOCKQUOTE

The BLOCKQUOTE element indicates that its contents constitute a quotation.

The BLOCKQUOTE element has no attributes. It is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

BODY

The BODY element contains the visible contents of the document.

The BODY element has eight optional attributes:

ALINK=colorThe value specifies the color for the active link (the link currently selected by the user).
BACKGROUND=stringThe value specifies the URL of an image file that will be tiled to form the background.
BGCOLOR=colorThe value specifies the color for the background.
LINK=colorThe value specifies the color of unvisited links.
ONLOAD=stringThe value specifies a JavaScript expression to be executed when the Web page finishes loading.
ONUNLOAD=stringThe value specifies a JavaScript expression to be executed when the user leaves the Web page.
TEXT=colorThe value specifies the color of ordinary text.
VLINK=colorThe value specifies the color of visited links.

The BODY element is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

BR (Line Break)

The BR element forces a line break. It has one optional attribute, CLEAR=string, where the value indicates how far down the browser should space until the indicated margin is clear of text and images. Valid values include left, right, and all.

The BR element is an empty element.

CAPTION

The CAPTION element defines a table caption. It has two attributes:

ALIGN=stringThe value indicates how the caption should be horizontally aligned with its table. Valid values include top, bottom, left, and right.
ID=stringThe value defines a hypertext link target.

The CAPTION element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

CENTER

The CENTER element indicates that the browser should horizontally center the contained text. It has no attributes. The CENTER element is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

CITE

The CITE element indicates that the contained text is a citation.

There are no attributes. The CITE element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

CODE

The CODE element indicates that the contained text is computer code and should be rendered in a suitable font. This element is recommended for short, single-line text; the PRE element is the element of choice for longer text, especially multiline text.

There are no attributes. The CODE element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

DD (Definition Description)

The DD element contains the definition portion of a definition list item. It has no attributes, and is a container element that may contain content text and A, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DL, EM, FONT, FORM, I, IMG, KBD, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

DIR (Directory)

The DIR element creates a list of short text items, such as file names. It has no attributes, and is a container element that may contain LI elements and their contents. A DIR element cannot contain APPLET, BLOCKQUOTE, CENTER, DIR, DL, FORM, MENU, OL, P, PRE, TABLE, or UL elements.

DIV (Division)

The DIV element breaks a document into major subdivisions. It has five attributes:

ALIGN=stringThe value specifies the horizontal alignment of the division. Valid values include left, center, and right.
CLEAR=stringThe value indicates how far down the browser should space until the indicated margin is clear of text and images. Valid values include left, right, and all.
ID=stringThe value defines a hypertext link target.
NEEDS=numberThe value specifies the minimal width required for this element.
NOWRAPThis attribute disables line wrap.

The DIV element is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

DL (Definition List)

The DL element contains a list of definitions. It has one attribute, COMPACT, which suggests that the list be rendered in a more compact form.

The DL element is a container element that may contain DD and DT elements.

DT (Definition Term)

The DT element contains a term in a list of definitions. It has no attributes, and is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

EM (Emphasis)

The EM element indicates that the browser should emphasize the contents. Browsers typically render the contents in an italic font.

There are no attributes. The EM element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

FONT

The FONT element defines the font size for contained text. The size may be absolute or relative; the browser adds the base font value to relative font sizes. This element has two attributes:

COLOR=colorThe value specifies the color for normal text within the FONT element.
SIZE=stringThe value may be a number (absolute size) or a number preceded by a + or - character (relative size).

The FONT element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

FORM

The FORM element defines a block of input fields that the user may fill in. The browser usually sends the user's data to a CGI application on the server. If the GET method is used, the CGI application can access an environment variable with the name QUERY_STRING. If the POST method is used, the CGI application can read the data from the standard input stream (stdin); the environment variable CONTENT_LENGTH contains the length of the data. Data is sent as name=value pairs separated by ampersands (&). The name=value pairs are URL-encoded-spaces are converted to pluses (+) and some characters are converted to a percent (%) character followed by the character's two-digit hexadecimal value.

The FORM element has six attributes:

ACTION=stringThe value specifies either a CGI URL or a mailto: URL. This attribute is mandatory.
ENCTYPE=stringThe value specifies the MIME encoding for the data when it is sent to the server. The values can be application/x-www-form-urlencoded (the default value) or multipart/form-data.
METHOD=stringThe value specifies how the data should be sent. The valid values are GET (the default) and POST.
NAME=stringThe value specifies the name of the corresponding JavaScript form object
ONSUBMIT=stringThe value specifies a JavaScript expression to be executed when the user clicks on the SUBMIT button.
TARGET=stringThe value specifies the name of a window or frame object into which the form responses will be written.

A FORM element is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, H1, H2, H3, H4, H5, H6, HR, I, IMG, INPUT, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SELECT, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TEXTAREA, TT, UL, VAR, and WBR elements. A FORM element may not contain another FORM element. A FORM element must contain at least one INPUT, SELECT, or TEXTAREA element.

FRAME

The FRAME element defines a frame, which is a subsection of the browser screen. It has six attributes:

MARGINHEIGHT= numberThe value specifies the size of the top and bottom margins of the frame. The value cannot be zero; you cannot use this attribute to erase the line between frames, and you cannot make the value so large as to squeeze another frame out of existence. If you do not use this attribute, the browser sets the upper and lower margins as it sees fit.
MARGINWIDTH= numberThe value specifies the size of the left and right margins of the frame. The value cannot be zero; you cannot use this attribute to erase the line between frames, and you cannot make the value so large as to squeeze another frame out of existence. If you do not use this attribute, the browser sets the left and right margins as it sees fit.
NAME=stringThe value is assigned to its frame so that the frame can be targeted by other links. This is the corresponding frame object's name attribute. By default, frames are unnamed.
NORESIZEThis attribute prevents the user from being able to resize this frame. Frames that share an edge with this frame cannot be resized if doing so would force this frame to be resized.
SCROLLING=stringThe value indicates how scroll bars should be used with the frame. Valid values are yes, no, and auto. The browser will always display the scroll bar if the value is yes. The browser will never display the scrollbar if the value is no. The browser will display the scrollbar as it sees fit if the value is auto. The default value is auto.
SRC=stringThe value specifies the URL for the document to be loaded into the frame. The frame will be empty if you do not use this attribute. The frame will also be empty if the specified URL happens to be the URL of an ancestor to this frame. This helps prevent infinite recursion.

The FRAME element is an empty element.

FRAMESET

The FRAMESET element defines a set of frames and how the containing window or frame will be divided to hold them.

A FRAMESET element has four attributes:

COLS=stringThe value describes how the columns of frames will be allocated window space.
ONLOAD=stringThe value specifies a JavaScript expression to be executed when the Web page has been loaded.
ONUNLOAD=stringThe value specifies a JavaScript expression to be executed when the user leaves the Web page.
ROWS=stringThe value describes how the rows of frames will be allocated window space.

A FRAMESET element must have either a COLS or a ROWS attribute, but not both. The COLS and ROW attribute values consist of frame widths or heights separated by commas. There should be no spaces in the value, and there should be one frame width or height for each FRAME or FRAMESET contained in the FRAMESET element. Frame widths and heights may be numbers, percentages (number followed by a percent sign), or relative values (an asterisk preceded by an optional number). Values that are numbers specify the height or width of the corresponding FRAME or FRAMESET element in pixels. Percentage values specify the percentage of the available space that should be allocated to the corresponding FRAME or FRAMESET element. Relative valued elements are allocated after all number and percentage valued elements have been allocated. If there are no relative values and the percentage values do not add up to 100 percent, the browser will adjust the percentage values to add up to 100 percent.

A FRAMESET element is a container element that may contain FRAME, NOFRAME, and FRAMESET elements.

H1, H2, H3, H4, H5, and H6 (Headings)

The H1, H2, H3, H4, H5, and H6 elements create headings. The most prominent is H1 and the least prominent is H6. These elements have three attributes:

ALIGN=stringThe value specifies the horizontal alignment of the heading. Valid values include left, center, right, and justify.
CLEAR=stringThe value indicates how far down the browser should space until the indicated margin is clear of text and images. Valid values include left, right, and all.
ID=stringThe value defines a hypertext link target.

Heading elements are container elements that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

HEAD

The HEAD element contains information about the document. It has no attributes and is a container element that may contain BASE, ISINDEX, LINK, META, NEXTID, SCRIPT, and TITLE elements. A TITLE element is considered mandatory by HTML specifications, but if the document is intended solely as a frame within a larger document, the TITLE element will be ignored and is not necessary. The NEXTID element is used only by automated hypertext editors, and its use is not recommended.

HR (Horizontal Rule)

The HR element draws a horizontal line across the page. There are four attributes:

ALIGN=stringThe value specifies the horizontal alignment of the rule. Valid values include left, center, and right.
NOSHADEThis attribute indicates that the rule should not include shading.
SIZE=numberThe value specifies the thickness of the line.
WIDTH=stringThe value specifies the width of the line, possibly as a percentage of the window width.

The HR element is an empty element.

HTML

The HTML element contains the entire document. It has no attributes, and it should contain a HEAD element followed by a BODY or FRAMESET element. In your JavaScript code, either or both elements may be superfluous.

I (Italic)

The I element specifies that the browser should render the contents in an italic font.

There are no attributes. The I element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

IMG (Image)

The IMG element embeds an inline image in the document. The image may be used as an image map-an image that contains clickable areas that act as a links to other URLs.

An image has height and width. You can specify these two quantities in the IMG element. Although they are not mandatory, there are two good reasons to treat them as mandatory:

The IMG element has 11 attributes:

ALIGN=stringThe value specifies the horizontal alignment of the image. Valid values include left, right, center, top, texttop, middle, absmiddle, baseline, bottom, and absbottom.
ALT=stringThe value provides text that a nongraphics browser may display instead of the image.
BORDER=numberThe value specifies the thickness of the border around the image.
HEIGHT=numberThe value specifies the height, in pixels, of the image. For pages using JavaScript, this attribute is mandatory.
HSPACE=numberThe value specifies how far, in pixels, to separate the image from text on either side.
ISMAPThis attribute indicates that the image is a server-side image map. To be useful, an IMG element with an ISMAP attribute has to be enclosed within an A element that has an HREF attribute (a link object). When the user clicks on a point in the image, the coordinates of the point are sent to the URL specified in the enclosing A element's HREF attribute. The URL is typically the location of a CGI application on the server.
LOWSRC=stringThe value specifies the URL of a lower resolution version of the image that can be quickly loaded. The idea is that, as time permits, the browser will replace the image with the real image.
SRC=stringThe value specifies the URL of the image file. This attribute is mandatory.
USEMAP=stringThe value specifies the relative URL of a MAP element; this image is a client-side image map.
VSPACE=numberThe number value specifies how far, in pixels, to separate the image from text above and below it.
WIDTH=numberThe number value specifies the width, in pixels, of the image. For pages using JavaScript, this attribute is mandatory.

The IMG element is an empty element.

INPUT

The INPUT element creates an input field. There are nine types of input fields.

The INPUT element has 13 attributes:

ALIGN=stringThe value specifies the alignment of the field on the page. Valid values include top, middle, and bottom.
CHECKEDThis attribute is used for checkbox and radio button input fields and specifies that the field be in the selected state.
MAXLENGTH= numberThe value specifies the maximum length for text in a text or password input field.
NAME=stringThe value specifies the name of the field. This attribute is mandatory. All radio fields that define a set of radio buttons must have the same name value.
ONBLUR=stringThe value specifies a JavaScript expression to be executed when the user transfers focus from this input field to another. This applies to password and text fields.
ONCHANGE= stringThe value specifies a JavaScript expression to be executed when the user changes the data in the field and presses Enter or transfers focus from this input field to another. This applies to text fields.
ONCLICK= stringThe value specifies a JavaScript expression to be executed when the user clicks on the INPUT element. This applies to button, checkbox, radio, reset, and submit fields.
ONFOCUS= stringThe value specifies a JavaScript expression to be executed when the user clicks on the INPUT element. This applies to password and text fields.
ONSELECT= stringThe value specifies a JavaScript expression to be executed when the user highlights some or all of the INPUT field's contents. This applies to password and text fields.
SIZE=numberThe value specifies the size of the field. For text and password fields, this is the number of characters that can be entered in the box without scrolling.
SRC=stringThe value specifies the URL of the image for an image field.
TYPE=stringThe value specifies the kind of field. Valid values are button, checkbox, hidden, image, password, radio, reset, submit, and text. This attribute is mandatory.
VALUE=stringThe value used depends on the field type. It specifies the initial value displayed in a text field. It specifies the button label for a button, reset, or submit field. It specifies the value returned to the server for a checkbox or radio field. It specifies a default (undisplayable) value for a password field. It specifies the initial (unseen) value for a hidden field.

The INPUT element is an empty element.

ISINDEX (Is Indexed)

The ISINDEX element indicates that the document is a searchable index. It has one attribute:

PROMPT=stringThe string value specifies a string to be used before the text input field of the index. The default value is "This is a searchable index. Enter search keywords:".

The ISINDEX element is an empty element.

KBD (Keyboard)

The KBD element specifies that the browser should render contained text as keyboard input.

There are no attributes. The KBD element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

LI (List Item)

The LI element creates an item in a list. It has two attributes:

TYPE=stringThe value specifies the type of bullet or numbering to be used in front of the contained text. Valid values include disc, circle, square, a, A, i, I, and 1. A and a refer to lowercase and uppercase letters; I and i refer to lowercase and uppercase roman numerals; 1 refers to ordinary numerals.
VALUE=numberThe value indicates where to start numbering for letters, Roman numerals, and numerals. The number is incremented with each LI element that follows. A value of 6, as an example, would be represented as F or f (letters), VI or vi (roman numerals), or 6 (numerals).

The LI element is a container element that may contain content text and A, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DL, EM, FONT, FORM, I, IMG, KBD, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements. It may not contain another LI element.

LINK

The LINK element describes an association with another document. The LINK element is rarely used; its chief value lies in statically documenting an association with another document. It has two attributes:

HREF=stringThe value specifies the URL of the other document. This attribute is mandatory.
TITLE=stringThe value specifies the title of the other document.

The LINK element is an empty element.

MAP

The MAP element describes a set of selectable areas within a client-side image map. It has one mandatory attribute, NAME=string, where the value gives a name that can be used by the IMG element in its USEMAP attribute.

The MAP element is a container element that contains only AREA elements.

MENU

The MENU element contains a list of items. It has no attributes, and is a container element that may contain APPLET, BLOCKQUOTE, CENTER, DIR, DL, FORM, LI, OL, P, PRE, TABLE, and UL elements.

META (Document Meta-Information)

The META element adds information to the document's HEAD element that does not fit anywhere else. It has three attributes:

CONTENT=stringThe value specifies the content associated with this element. This attribute is mandatory.
HTTP-EQUIV= stringThe value specifies a field to be sent by the server in an HTTP response header.
NAME=stringThe value specifies a string that the client browser may be expected to understand.

You should use either the HTTP-EQUIV or the NAME attribute, but not both.

The META element is an empty element.

NOBR (No Break)

The NOBR element prevents the browser from inserting line breaks. It has no attributes. The NOBR element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

NOFRAME

The NOFRAME element allows you to provide content for browsers that do not understand FRAMESET and FRAME elements. It has no attributes, and is a container element that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BODY, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements.

OL (Ordered List)

The OL element contains a list that is strongly ordered in some fashion, such as an alphabetized list. It has three attributes:

COMPACTThis attribute advises the browser to display the list in a more compact fashion than it normally would.
START=numberThe value indicates where the first LI element should start numbering. The number is incremented with each subsequent LI element. A value of 6, as an example, would be represented as F or f (letters), VI or vi (Roman numerals), or 6 (numerals).
TYPE=stringThe value specifies how the list items should be numbered. Valid values include a (lowercase letters), A (uppercase letters), i (lowercase Roman numerals), I (uppercase Roman numerals), and 1 (numerals).

The OL element is a container element that may only contain LI elements.

OPTION

The OPTION element specifies an option within a SELECT element. It has two attributes:

SELECTEDThis attribute marks the option as selected.
VALUE=stringThe value is the value of the element when the form is submitted. If this attribute is not used, the value will be the text contained in the element.

The OPTION element is a container element that may only contain content text.

P (Paragraph)

The P element contains a paragraph. It forces a break before and after the contained text. In response to strings of empty P elements, some browsers will increase the thickness of the break; others will not. The P element has five attributes:

ALIGN=stringThe value specifies how the paragraph should be aligned. Valid values include left, center, and right.
CLEAR=stringThe value indicates how far down the browser should space until the indicated margin is clear of text and images. Valid values include left, right, and all.
ID=stringThe value defines a hypertext link target.
NEEDS=numberThe value specifies the minimal width needed for the paragraph.
NOWRAPThis attribute specifies that line wrap is disabled.

The P element is a container element and may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

PARAM (Applet Parameter)

The PARAM element specifies a parameter for the containing APPLET element. It has two attributes:

NAME=stringThe value specifies the name of a parameter. This attribute is mandatory.
VALUE=stringThe string value specifies the value of the parameter.

The PARAM element is an empty container.

PRE (Preformatted Text)

The PRE element specifies that the browser is to render text as is, with its embedded line breaks and spaces intact. It has one attribute, WIDTH=number, where the value specifies the width of the text in characters. The browser should break the line after reaching the specified number of characters.

The PRE element is a container element and may contain content text and the elements A, BR, and HR.

SAMP (Literal Characters)

The SAMP element indicates that the browser should render contained text as a sequence of literal characters.

There are no attributes. The SAMP element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

SCRIPT

The SCRIPT element contains JavaScript code. It has one attribute, LANGUAGE= string, which is used to specify the language. It has two values, LiveScript and JavaScript. There is very little difference between the two. You should always use the JavaScript value.

The SCRIPT element is a container element that contains content text as JavaScript code.

SELECT

The SELECT element specifies a set of options from which the user may choose. It has six attributes:

MULTIPLEThis attribute indicates that more than one enclosed OPTION element may be selected at the same time.
NAME=stringThe value specifies the name of the variable. This attribute is mandatory.
ONBLUR=stringThe value specifies a JavaScript expression to be executed when focus is moved from this element to another.
ONCHANGE= stringThe value specifies a JavaScript expression to be executed when the user changes the selected value and focus is moved from this element to another.
ONFOCUS= stringThe value specifies a JavaScript expression to be executed when the user gives this element focus.
SIZE=numberThe value specifies the number of displayed options.

The SELECT element is a container that may only contain OPTION elements.

SMALL

The SMALL element specifies that the browser should render the contents in a smaller than normal font.

There are no attributes. The SMALL element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

STRIKE

The STRIKE element specifies that the browser should render the contents in a strikethrough font.

There are no attributes. The STRIKE element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

STRONG (Strong Emphasis)

The STRONG element indicates that the browser should strongly emphasize the contained text.

There are no attributes. The STRONG element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

SUB (Subscript)

The SUB element specifies that the browser should render the contents as subscript.

There are no attributes. The SUB element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

SUP (Superscript)

The SUP element specifies that the browser should render the contents as superscript.

There are no attributes. The SUP element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

TABLE

The TABLE element defines a table. It has ten attributes:

ALIGN=stringThe value specifies the alignment of the table. Valid values include bleedleft, left, center, right, bleedright, and justify. The default value is center.
BORDER=numberThe value specifies the width of the border around the table. A value of 0 indicates no border.
CELLPADDING= numberThe value specifies the width of the space, in pixels, between the contents of each cell and its border. The default value is 1.
CELLSPACING= numberThe value specifies the distance between cells, in pixels. The default value is 2.
CLEAR=stringThe value specifies that the browser should space down the page until the indicated margin is clear of text and images. The value may be left, right, or all.
ID=stringThe value specifies a name that can be used in a fragment URL.
NEEDS=numberThe value specifies the minimal width needed for this element.
NOWRAPThis attribute specifies that line wrap is disabled.
UNITS=stringThe value specifies the units of measure. Valid values are em, pixels, and relative. The default value is em. An em is a printer's measurement, the width of the letter "M."
WIDTH=numberThe value specifies the width of the table in pixels or as a percentage of the width that the browser would try to put it in.

The TABLE element is a container element that may contain CAPTION and TR elements.

TD (Table Data) and TH (Table Header)

The TD element specifies the contents of a table cell. The TH element creates a header cell for a table. Typically, the browser will render the text of a TH element in a bold font; this is the only real difference between a TH element and a TD element.

The TD and TH elements have seven attributes:

ALIGN=stringThe value specifies the alignment that should be used for the data. Valid values are left, center, right, and justify.
COLSPAN=numberThe value specifies the number of columns that this cell spans.
ID=stringThe value specifies a name that can be used in fragment URLs.
NOWRAPThis attribute specifies that line wrap is disabled.
ROWSPAN=numberThe value specifies the number of rows that this cell spans.
VALIGN=stringThe value specifies the vertical alignment that should be used for the data. Valid values are top, middle, bottom, and baseline.
WIDTH=numberThe value specifies the width in pixels or as a percentage of the calculated width that the cell data should be forced to occupy.

TD and TH elements are container elements that may contain content text and A, ADDRESS, APPLET, B, BASEFONT, BIG, BLINK, BLOCKQUOTE, BR, CENTER, CITE, CODE, DIR, DIV, DL, EM, FONT, FORM, H1, H2, H3, H4, H5, H6, HR, I, IMG, KBD, MAP, MENU, NOBR, OL, P, PRE, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TABLE, TT, UL, VAR, and WBR elements. An interesting "gotcha" is that a TD or TH element containing an IMG element, and nothing else, must contain no line breaks in the source. In other words,

<TD>
<IMG SRC="image.gif" WIDTH=4Ø HEIGHT=2Ø>
</TD>

will result in spaces before and after the image. Usually the goal is to have the image fill the cell completely. Here is the right way to do it:

<TD><IMG SRC="image.gif" WIDTH=4Ø HEIGHT=2Ø></TD>

TEXTAREA

The TEXTAREA element defines an input field in which multiple lines may be entered. It has eight attributes:

COLS=numberThe value specifies the number of columns for the text box. This attribute is mandatory.
NAME=stringThe value specifies the name of the variable. This attribute is mandatory.
ONBLUR=stringThe value specifies a JavaScript expression to be executed when the user moves focus from this element to another input field.
ONCHANGE=stringThe value specifies a JavaScript expression to be executed when the user changes the data in the field and moves focus to another input field.
ONFOCUS=stringThe value specifies a JavaScript expression to be executed when the user moves focus from another input field to this field.
ONSELECT=stringThe value specifies a JavaScript expression to be executed when the user highlights some or all of the text in the field.
ROWS=numberThe value specifies the number of rows for the text box. This attribute is mandatory.
WRAP=stringThe value specifies how line wrap should be performed. Valid values include off, soft, and hard. The default value is off, meaning that lines are sent as entered. Soft wrap specifies that long lines are displayed with line wrapping, but the lines are sent as entered. Hard wrap specifies that long lines are displayed and sent with line wrapping.

The TEXTAREA element is a container element that may only contain content text.

TITLE

The TITLE element contains the document title, which is usually displayed in the browser window's decoration. It has no attributes, and is a container element that may only contain content text. You should limit the length of this element to 64 or fewer characters.

TR (Table Row)

The TR element defines a table row. It has four attributes:

ALIGN=stringThe value specifies the alignment that should be used for the data. Valid values are left, center, right, and justify.
ID=stringThe value specifies a name that can be used in fragment URLs.
NOWRAPThis attribute specifies that line wrap is disabled.
VALIGN=stringThe value specifies the vertical alignment that should be used for the data. Valid values are top, middle, bottom, and baseline.

The TR element is a container element that may contain TD and TH elements.

TT (Teletype)

The TT element specifies that the browser should render the contents in a fixed width teletype font.

There are no attributes. The TT element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

UL (Unordered List)

The UL element creates a list that is not ordered. It has two attributes:

COMPACTThis attribute specifies that the browser should try to render the contents in a more compact way.
TYPE=stringThe value specifies how the list items should be numbered. Valid values include disc (a filled circle), circle (an empty circle), and square.

The UL element is a container element that may contain LI elements.

VAR (Variable)

The VAR element specifies that the browser should render the contained text as a variable name.

There are no attributes. The VAR element is a container element that may contain content text and A, B, BASEFONT, BIG, BLINK, BR, CITE, CODE, EM, FONT, I, IMG, KBD, NOBR, SAMP, SMALL, STRIKE, STRONG, SUB, SUP, TT, VAR, and WBR elements.

WBR (Word Break)

The WBR element informs the browser where it can break a word. Unlike BR, it does not force a line break. You can use WBR elements within a NOBR element to dictate precisely where the browser may break a line and where it may not. The WBR element has no attributes and is an empty element.