HTML 3.2 TAG REFERENCE


Adapted from the official W3C HTML 3.2 Reference.


The Structure of HTML documents

HTML 3.2 Documents start with a <!DOCTYPE> declaration followed by an HTML element containing a HEAD and then a BODY element:

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  <HTML>
  <HEAD>
  <TITLE>A study of population dynamics</TITLE>
  ... other head elements
  </HEAD>
  <BODY>
  ... document body
  </BODY>
  </HTML>

The HEAD element

This contains the document head, but you can always omit both the start and end tags for HEAD. The contents of the document head is an unordered collection of the following elements:

TITLE defines the document title, and is always needed.

TITLE is a container and requires both start and end tags.

Example TITLE element:

    <TITLE>A study of population dynamics</TITLE>

The BODY element

This contains the document body. Both start and end tags for BODY may be omitted. The body can contain a wide range of elements:

The key attributes are: BACKGROUND, BGCOLOR, TEXT, LINK, VLINK and ALINK. These can be used to set a repeating background image, plus background and foreground colors for normal text and hypertext links.

Example:

 <body bgcolor=white text=black link=red vlink=maroon alink=fuchsia>
bgcolor
Specifies the background color for the document body. See below for the syntax of color values.
text
Specifies the color used to stroke the document's text. This is generally used when you have changed the background color with the BGCOLOR or BACKGROUND attributes.
link
Specifies the color used to stroke the text for unvisited hypertext links.
vlink
Specifies the color used to stroke the text for visited hypertext links.
alink
Specifies the highlight color used to stroke the text for hypertext links at the moment the user clicks on the link.
background
Specifies a URL for an image that will be used to tile the document background.

Colors are given in the sRGB color space as hexadecimal numbers (e.g. COLOR="#C0FFC0"), or as one of 16 widely understood color names. These colors were originally picked as being the standard 16 colors supported with the Windows VGA palette.

Color names and sRGB values

Black = "#000000"

Green = "#008000"

Silver = "#C0C0C0"

Lime = "#00FF00"

Gray = "#808080"

Olive = "#808000"

White = "#FFFFFF"

Yellow = "#FFFF00"

Maroon = "#800000"

Navy = "#000080"

Red = "#FF0000"

Blue = "#0000FF"

Purple = "#800080"

Teal = "#008080"

Fuchsia = "#FF00FF"

Aqua = "#00FFFF"

Block and Text level elements

Most elements that can appear in the document body fall into one of two groups: block level elements which cause paragraph breaks, and text level elements which don't. Common block level elements include H1 to H6 (headers), P (paragraphs) LI (list items), and HR (horizontal rules). Common text level elements include EM, I, B and FONT (character emphasis), A (hypertext links), IMG and BR (line breaks). Note that block elements generally act as containers for text level and other block level elements (excluding headings and address elements), while text level elements can only contain other text level elements. The exact model depends on the element.

Headings

There are six levels of headers from H1 (the most important) to H6 (the least important).

H1, H2, H3, H4, H5 and H6 are used for document headings. You always need the start and end tags. H1 elements are more important than H2 elements and so on, so that H6 elements define the least important level of headings. More important headings are generally rendered in a larger font than less important ones. Use the optional ALIGN attribute to set the text alignment within a heading, e.g.

  <H1 ALIGN=CENTER> ... centered heading ... </H1>

The default is left alignment, but this can be overridden by an enclosing DIV or CENTER element.

ADDRESS

The ADDRESS element requires start and end tags, and specifies information such as authorship and contact details for the current document. Browsers should render the content with paragraph-breaks before and after. Note that the content is restricted to paragraphs, plain text and text-like elements as defined by the %text entity.

Example:

<ADDRESS>
Newsletter editor<BR>
J.R. Brown<BR>
8723 Buena Vista, Smallville, CT 01234<BR>
Tel: +1 (123) 456 7890
</ADDRESS>

Block elements

P paragraphs
The paragraph element requires a start tag, but the end tag can always be omitted. Use the ALIGN attribute to set the text alignment within a paragraph, e.g. <P ALIGN=RIGHT>
UL unordered lists
These require start and end tags, and contain one or more LI elements representing individual list items.
OL ordered (i.e. numbered) lists
These require start and end tags, and contain one or more LI elements representing individual list items.
DL definition lists
These require start and end tags and contain DT elements that give the terms, and DD elements that give corresponding definitions.
PRE preformatted text
Requires start and end tags. These elements are rendered with a monospaced font and preserve layout defined by whitespace and line break characters.
DIV document divisions
Requires start and end tags. It is used with the ALIGN attribute to set the text alignment of the block elements it contains. ALIGN can be one of LEFT, CENTER or RIGHT.
CENTER text alignment
Requires start and end tags. It is used to center text lines enclosed by the CENTER element. See DIV for a more general solution.
BLOCKQUOTE quoted passage
Requires start and end tags. It is used to enclose extended quotations and is typically rendered with indented margins.
FORM fill-out forms
Requires start and end tags. This element is used to define a fill-out form for processing by HTTP servers. The attributes are ACTION, METHOD and ENCTYPE. Form elements can't be nested.
HR horizontal rules
Not a container, so the end tag is forbidden. attributes are ALIGN, NOSHADE, SIZE and WIDTH.
TABLE can be nested
Requires start and end tags. Each table starts with an optional CAPTION followed by one or more TR elements defining table rows. Each row has one or more cells defined by TH or TD elements. attributes for TABLE elements are WIDTH, BORDER, CELLSPACING and CELLPADDING.

Paragraphs

The P element is used to markup paragraphs. It is a container and requires a start tag. The end tag is optional as it can always be inferred by the parser. Browsers should place paragraph breaks before and after P elements. The rendering is browser dependent, but text is generally wrapped to fit the space available.

Example:

    <P>This is the first paragraph.
    <P>This is the second paragraph.

Paragraphs are usually rendered flush left with a ragged right margin. The ALIGN attribute can be used to explicitly specify the horizontal alignment:

align=left
The paragraph is rendered flush left.
align=center
The paragraph is centered.
align=right
The paragraph is rendered flush right.

For example:

<p align=center>This is a centered paragraph.
<p align=right>and this is a flush right paragraph.

The default is left alignment, but this can be overridden by an enclosing DIV or CENTER element.

Lists

List items can contain block and text level items, including nested lists, although headings and address elements are excluded.

Unordered Lists

Unordered lists take the form:

    <UL>
      <LI> ... first list item
      <LI> ... second list item
      ...
    </UL>

The UL element is used for unordered lists. Both start and end tags are always needed. The LI element is used for individual list items. The end tag for LI elements can always be omitted. Note that LI elements can contain nested lists. The COMPACT attribute can be used as a hint to the browser to render lists in a more compact style.

The TYPE attribute can be used to set the bullet style on UL and LI elements. The permitted values are "disc", "square" or "circle". The default generally depends on the level of nesting for lists.

  • with <li type=disc>
  • with <li type=square>
  • with <li type=circle>

Ordered (i.e. numbered) Lists

Ordered (i.e. numbered) lists take the form:

    <OL>
      <LI> ... first list item
      <LI> ... second list item
      ...
    </OL>

The OL START attribute can be used to initialize the sequence number (by default it is initialized to 1). You can set it later on with the VALUE attribute on LI elements. Both of these attributes expect integer values. You can't indicate that numbering should be continued from a previous list, or to skip missing values without giving an explicit number.

The COMPACT attribute can be used as a hint to the browser to render lists in a more compact style. The OL TYPE attribute allows you to set the numbering style for list items:

Type Numbering style
1 Arabic numbers1, 2, 3, ...
a lower alphaa, b, c, ...
A upper alphaA, B, C, ...
i lower romani, ii, iii, ...
I upper romanI, II, III, ...

Definition Lists

Definition lists take the form:

  <DL>
    <DT> term name
    <DD> term definition
    ...
  </DL>

DT elements can only act as containers for text level elements, while DD elements can hold block level elements as well, excluding headings and address elements.

For example:

<DL>
<DT>Term 1<dd>This is the definition of the first term.
<DT>Term 2<dd>This is the definition of the second term.
</DL>

which could be rendered as:

Term 1
This is the definition of the first term.
Term 2
This is the definition of the second term.

The COMPACT attribute can be used with the DL element as a hint to the browser to render lists in a more compact style.

Preformatted Text

The PRE element can be used to include preformatted text. Browsers render this in a fixed pitch font, preserving spacing associated with white space characters such as space and newline characters. Automatic word-wrap should be disabled within PRE elements.

PRE has the same content model as paragraphs, excluding images and elements that produce changes in font size, e.g. IMG, BIG, SMALL, SUB, SUP and FONT.

A few Browsers support the WIDTH attribute. It provides a hint to the browser of the required width in characters. The browser can use this to select an appropriate font size or to indent the content appropriately.

Here is an example of a PRE element; a verse from Shelley (To a Skylark):

<PRE>
       Higher still and higher
         From the earth thou springest
       Like a cloud of fire;
         The blue deep thou wingest,
And singing still dost soar, and soaring ever singest.
</PRE>
which is rendered as:
       Higher still and higher
         From the earth thou springest
       Like a cloud of fire;
         The blue deep thou wingest,
And singing still dost soar, and soaring ever singest.

XMP, LISTING and PLAINTEXT

These are obsolete tags for preformatted text that predate the introduction of PRE. Browsers may support these for backwards compatibility. Authors should avoid using them in new documents!

DIV and CENTER

DIV elements can be used to structure HTML documents as a hierarchy of divisions. The ALIGN attribute can be used to set the default horizontal alignment for elements within the content of the DIV element. Its value is restricted to LEFT, CENTER or RIGHT, and is defined in the same way as for the paragraph element <P>.

Note that because DIV is a block-like element it will terminate an open P element. Other than this, Browsers are not expected to render paragraph breaks before and after DIV elements. CENTER is directly equivalent to DIV with ALIGN=CENTER. Both DIV and CENTER require start and end tags.

BLOCKQUOTE

This is used to enclose block quotations from other works. Both the start and end tags are required. It is often rendered indented, e.g.

They went in single file, running like hounds on a strong scent, and an eager light was in their eyes. Nearly due west the broad swath of the marching Orcs tramped its ugly slot; the sweet grass of Rohan had been bruised and blackened as they passed.

from "The Two Towers" by J.R.R. Tolkien.

FORM

This is used to define an HTML form, and you can have more than one form in the same document. Both the start and end tags are required. Forms can contain a wide range of HTML markup including several kinds of form fields such as single and multi-line text fields, radio button groups, checkboxes, and menus.

action
This specifies a URL which is either used to post forms via email, e.g. action="mailto:foo@bar.com", or used to invoke a server-side forms handler via HTTP, e.g. action="http://www.acme.com/cgi-bin/register.pl"
method
When the action attribute specifies an HTTP server, the method attribute determines which HTTP method will be used to send the form's contents to the server. It can be either GET or POST, and defaults to GET.
enctype
This determines the mechanism used to encode the form's contents. It defaults to application/x-www-form-urlencoded.

Further details on handling forms should be referenced from your ISP.

HR - horizontal rules

Horizontal rules may be used to indicate a change in topic. In a speech based browser, the rule could be rendered as a pause.

HR elements are not containers so the end tag is forbidden. The attributes are: ALIGN, NOSHADE, SIZE and WIDTH.

align
This determines whether the rule is placed at the left, center or right of the space between the current left and right margins for align=left, align=center or align=right respectively. By default, the rule is centered.
noshade
This attribute requests the browser to render the rule in a solid color rather than as the traditional two colour "groove".
size
This can be used to set the height of the rule in pixels.
width
This can be used to set the width of the rule in pixels (e.g. width=100) or as the percentage between the current left and right margins (e.g. width="50%"). The default is 100%.

Tables

Tables take the general form:

  <TABLE BORDER=3 CELLSPACING=2 CELLPADDING=2 WIDTH="80%">
  <TR><TD> first cell <TD> second cell
  <TR> ...
  ...
  </TABLE>

The attributes on TABLE are all optional. By default, the table is rendered without a surrounding border. The table is generally sized automatically to fit the contents, but you can also set the table width using the WIDTH attribute. BORDER, CELLSPACING and CELLPADDING provide further control over the table's appearence.

Each table row is contained in a TR element, although the end tag can always be omitted. Table cells are defined by TD elements for data and TH elements for headers. Like TR, these are containers and can be given without trailing end tags. TH and TD support several attributes: ALIGN and VALIGN for aligning cell content, ROWSPAN and COLSPAN for cells which span more than one row or column. A cell can contain a wide variety of other block and text level elements including form fields and other tables.

The TABLE element always requires both start and end tags. It supports the following attributes:

align
This takes one of the case insensitive values: LEFT, CENTER or RIGHT. It specifies the horizontal placement of the table relative to the current left and right margins. It defaults to left alignment, but this can be overridden by an enclosing DIV or CENTER element.
width
In the absence of this attribute the table width is automatically determined from the table contents. You can use the WIDTH attribute to set the table width to a fixed value in pixels (e.g. WIDTH=212) or as a percentage of the space between the current left and right margins (e.g. WIDTH="80%").
border
This attribute can be used to specify the width of the outer border around the table to a given number of pixels (e.g. BORDER=4). The value can be set to zero to suppress the border altogether. In the absence of this attribute the border should be suppressed. Note that some browsers also accept <TABLE BORDER> with the same semantics as BORDER=1.
cellspacing
In traditional desktop publishing software, adjacent table cells share a common border. This is not the case in HTML. Each cell is given its own border which is separated from the borders around neighboring cells. This separation can be set in pixels using the CELLSPACING attribute, (e.g. CELLSPACING=10). The same value also determines the separation between the table border and the borders of the outermost cells.
cellpadding
This sets the padding in pixels between the border around each cell and the cell's contents.

The TR or table row element requires a start tag, but the end tag can always be left out. TR acts as a container for table cells. It has two attributes:

align
Sets the default horizontal alignment of cell contents. It takes one of the case insensitive values: LEFT, CENTER or RIGHT and plays the same role as the ALIGN attribute on paragraph elements.
valign
This can be used to set the default vertical alignment of cell contents within each cell. It takes one of the case insensitive values: TOP, MIDDLE or BOTTOM to position the cell contents at the top, middle or bottom of the cell respectively.

The element for defining table cells is TD. The start tags for TD are always needed but the end tags can be left out. Table cells can have the following attributes:

nowrap
The presence of this attribute disables automatic word wrap within the contents of this cell (e.g. <TD NOWRAP>). This is equivalent to using the &nbsp; entity for non-breaking spaces within the content of the cell.
rowspan
This takes a positive integer value specifying the number of rows spanned by this cell. It defaults to one.
colspan
This takes a positive integer value specifying the number of columns spanned by this cell. It defaults to one.
align
Specifies the default horizontal alignment of cell contents, and overrides the ALIGN attribute on the table row. It takes the same values: LEFT, CENTER and RIGHT. If you don't specify an ALIGN attribute value on the cell, the default is left alignment for <td> and center alignment for <th> although you can override this with an ALIGN attribute on the TR element.
valign
Specifies the default vertical alignment of cell contents, overriding the VALIGN attribute on the table row. It takes the same values: TOP, MIDDLE and BOTTOM. If you don't specify a VALIGN attribute value on the cell, the default is middle although you can override this with a VALIGN attribute on the TR element.
width
Specifies the suggested width for a cell content in pixels excluding the cell padding. This value will normally be used except when it conflicts with the width requirements for other cells in the same column.
height
Specifies the suggested height for a cell content in pixels excluding the cell padding. This value will normally be used except when it conflicts with the height requirements for other cells in the same row.

Tables are commonly rendered in bas-relief, raised up with the outer border as a bevel, and individual cells inset into this raised surface. Borders around individual cells are only drawn if the cell has explicit content. White space doesn't count for this purpose with the exception of &nbsp;.


Text level elements

These don't cause paragraph breaks. Text level elements that define character styles can generally be nested. They can contain other text level elements but not block level elements.

Font style elements

These all require start and end tags, e.g.

  This has some <B>bold text</B>.

Text level elements must be properly nested - the following is in error:

  This has some <B>bold and <I></B>italic text</I>.
Browsers should do their best to respect nested emphasis, e.g.
  This has some <B>bold and <I>italic text</I></B>.
TT teletype or monospaced text
I italic text style
B bold text style
U underlined text style
STRIKE strike-through text style
BIG places text in a large font
SMALL places text in a small font
SUB places text in subscript style
SUP places text in superscript style

Phrase Elements

These all require start and end tags, e.g.

  This has some <EM>emphasized text</EM>.
EM basic emphasis typically rendered in an italic font
STRONG strong emphasis typically rendered in a bold font
CODE used for extracts from program code
SAMP used for sample output from programs, and scripts etc.

Form fields

INPUT, SELECT and TEXTAREA are only allowed within FORM elements. INPUT can be used for a variety of form fields including single line text fields, password fields, checkboxes, radio buttons, submit and reset buttons, hidden fields, file upload, and image buttons. SELECT elements are used for single or multiple choice menus. TEXTAREA elements are used to define multi-line text fields. The content of the element is used to initialize the field.

INPUT text fields, radio buttons, check boxes, ...

INPUT elements are not containers and so the end tag is forbidden.

type
Used to set the type of input field:

type=text (the default)
A single line text field whose visible size can be set using the size attribute, e.g. size=40 for a 40 character wide field. Users should be able to type more than this limit though with the text scrolling through the field to keep the input cursor in view. You can enforce an upper limit on the number of characters that can be entered with the maxlength attribute. The name attribute is used to name the field, while the value attribute can be used to initialize the text string shown in the field when the document is first loaded.
    <input type=text size=40 name=user value="your name">
type=password
This is like type=text, but echoes characters using a character like * to hide the text from prying eyes when entering passwords. You can use size and maxlength attributes to control the visible and maximum length exactly as per regular text fields.
    <input type=password size=12 name=pw>
type=checkbox
Used for simple Boolean attributes, or for attributes that can take multiple values at the same time. The latter is represented by several checkbox fields with the same name and a different value attribute. Each checked checkbox generates a separate name/value pair in the submitted data, even if this results in duplicate names. Use the checked attribute to initialize the checkbox to its checked state.
    <input type=checkbox checked name=uscitizen value=yes>
type=radio
Used for attributes which can take a single value from a set of alternatives. Each radio button field in the group should be given the same name. Radio buttons require an explicit value attribute. Only the checked radio button in the group generates a name/value pair in the submitted data. One radio button in each group should be initially checked using the checked attribute.
    <input type=radio name=age value="0-12">
    <input type=radio name=age value="13-17">
    <input type=radio name=age value="18-25">
    <input type=radio name=age value="26-35" checked>
    <input type=radio name=age value="36-">
type=submit
This defines a button that users can click to submit the form's contents to the server. The button's label is set from the value attribute. If the name attribute is given then the submit button's name/value pair will be included in the submitted data. You can include several submit buttons in the form. See type=image for graphical submit buttons.
    <input type=submit value="Party on ...">
type=image
This is used for graphical submit buttons rendered by an image rather than a text string. The URL for the image is specified with the src attribute. The image alignment can be specified with the align attribute. In this respect, graphical submit buttons are treated identically to IMG elements, so you can set align to left, right, top, middle or bottom.
type=reset
This defines a button that users can click to reset form fields to their initial state when the document was first loaded. You can set the label by providing a value attribute. Reset buttons are never sent as part of the form's contents.
    <input type=reset value="Start over ...">
type=file
This provides a means for users to attach a file to the form's contents. It is generally rendered by text field and an associated button which when clicked invokes a file browser to select a file name. The file name can also be entered directly in the text field. Just like type=text you can use the size attribute to set the visible width of this field in average character widths. You can set an upper limit to the length of file names using the maxlength attribute.
type=hidden
These fields should not be rendered and provide a means for servers to store state information with a form. This will be passed back to the server when the form is submitted.
    <input type=hidden name=customerid value="c2415-345-8563">
name
Used to define the property name that will be used to identify this field's content when it is submitted to the server.
value
Used to initialize the field, or to provide a textual label for submit and reset buttons.
checked
The presence of this attribute is used to initialize checkboxes and radio buttons to their checked state.
size
Used to set the visible size of text fields to a given number of average character widths, e.g. size=20
maxlength
Sets the maximum number of characters permitted in a text field.
src
Specifies a URL for the image to use with a graphical submit button.
align
Used to specify image alignment for graphical submit buttons. It is defined just like the IMG align attribute and takes one of the values: top, middle, bottom, left or right, defaulting to bottom.

SELECT menus

SELECT is used to define select one from many or many from many menus. SELECT elements require start and end tags and contain one or more OPTION elements that define menu items. One from many menus are generally rendered as drop-down menus while many from many menus are generally shown as list boxes.

Example:

    <SELECT NAME="flavor">
    <OPTION VALUE=a>Vanilla
    <OPTION VALUE=b>Strawberry
    <OPTION VALUE=c>Rum and Raisin
    <OPTION VALUE=d>Peach and Orange
    </SELECT>

SELECT attributes:

name
This specifies a property name that is used to identify the menu choice when the form is submitted to the server. Each selected option results in a property name/value pair being included as part of the form's contents.
size
This sets the number of visible choices for many from many menus.
multiple
The presence of this attribute signifies that the users can make multiple selections. By default only one selection is allowed.

OPTION attributes:

selected
When this attribute is present, the option is selected when the document is initially loaded. It is an error for more than one option to be so selected for one from many menus.
value
Specifies the property value to be used when submitting the form's content. This is combined with the property name as given by the name attribute of the parent SELECT element.

TEXTAREA multi-line text fields

TEXTAREA elements require start and end tags. The content of the element is restricted to text and character entities. It is used to initialize the text that is shown when the document is first loaded.

Example:

    <TEXTAREA NAME=address ROWS=4 COLS=40>
    Your address here ...
    </TEXTAREA>
name
This specifies a property name that is used to identify the textarea field when the form is submitted to the server.
rows
Specifies the number of visible text lines. Users should be able to enter more lines that this, so Browsers should provide some means to scroll through the contents of the textarea field when the contents extend beyond the visible area.
cols
Specifies the visible width in average character widths. Users should be able to enter longer lines that this, so Browsers should provide some means to scroll through the contents of the textarea field when the contents extend beyond the visible area. Browsers may wrap visible text lines to keep long lines visible without the need for scrolling.

Special Text level Elements

A (Anchor), IMG, FONT, BR and MAP.

The A (anchor) element

Anchors can't be nested and always require start and end tags. They are used to define hypertext links and also to define named locations for use as targets for hypertext links, e.g.

   The way to <a href="hands-on.html">happiness</a>.

and also to define named locations for use as targets for hypertext links, e.g.

   <h2><a name=mit>545 Tech Square - Hacker's Paradise</a></h2>
name
This should be a string defining unique name for the scope of the current HTML document. NAME is used to associate a name with this part of a document for use with URLs that target a named section of a document.
href
Specifies a URL acting as a network address for the linked resource. This could be another HTML document, a PDF file or an image etc.

IMG - inline images

Used to insert images. IMG is an empty element and so the end tag is forbidden. Images can be positioned vertically relative to the current textline or floated to the left or right. See BR with the CLEAR attribute for control over textflow.

e.g.  <IMG SRC="canyon.gif" ALT="Grand Canyon">

IMG elements support the following attributes:

src
This attribute is required for every IMG element. It specifies a URL for the image resource, for instance a GIF, JPEG or PNG image file.
alt
This is used to provide a text description of the image and is vital for interoperability with speech-based and text only Browsers.
align
This specifies how the image is positioned relative to the current textline in which it occurs:
align=top
positions the top of the image with the top of the current text line. Browsers vary in how they interpret this. Some only take into account what has occurred on the text line prior to the IMG element and ignore what happens after it.
align=middle
aligns the middle of the image with the baseline for the current textline.
align=bottom
is the default and aligns the bottom of the image with the baseline.
align=left
floats the image to the current left margin, temporarily changing this margin, so that subsequent text is flowed along the image's righthand side. The rendering depends on whether there is any left aligned text or images that appear earlier than the current image in the markup. Such text (but not images) generally forces left aligned images to wrap to a new line, with the subsequent text continuing on the former line.
align=right
floats the image to the current right margin, temporarily changing this margin, so that subsequent text is flowed along the image's lefthand side. The rendering depends on whether there is any right aligned text or images that appear earlier than the current image in the markup. Such text (but not images) generally forces right aligned images to wrap to a new line, with the subsequent text continuing on the former line.

Note that some browsers introduce spurious spacing with multiple left or right aligned images. As a result authors can't depend on this being the same for browsers from different vendors.

width
Specifies the intended width of the image in pixels. When given together with the height, this allows Browsers to reserve screen space for the image before the image data has arrived over the network.
height
Specifies the intended height of the image in pixels. When given together with the width, this allows Browsers to reserve screen space for the image before the image data has arrived over the network.
border
When the IMG element appears as part of a hypertext link, the browser will generally indicate this by drawing a colored border (typically blue) around the image. This attribute can be used to set the width of this border in pixels. Use border=0 to suppress the border altogether. Browsers are recommended to provide additional cues that the image is clickable, e.g. by changing the mouse pointer.
hspace
This can be used to provide white space to the immediate left and right of the image. The HSPACE attribute sets the width of this white space in pixels. By default HSPACE is a small non-zero number.
vspace
This can be used to provide white space above and below the image The VSPACE attribute sets the height of this white space in pixels. By default VSPACE is a small non-zero number.
usemap
This can be used to give a URL fragment identifier for a client-side image map defined with the MAP element.

FONT

Requires start and end tags. This allows you to change the font typeface, size and/or color for the enclosed text. The attributes are: SIZE, COLOR, and FACE. Font sizes are given in terms of a scalar range defined by the browser with no direct mapping to point sizes etc.

size
This sets the font size for the contents of the font element. You can set size to an integer ranging from 1 to 7 for an absolute font size, or specify a relative font size with a signed integer value, e.g. size="+1" or size="-2".
color
Used to set the color to stroke the text. Colors are given as RGB in hexadecimal notation or as one of 16 widely understood color names defined as per the BGCOLOR attribute on the BODY element.
face
Set the typeface of the enclosed text and accepts a comma separated list of font names in order of preference. This is used to search for an installed font with the corresponding name. The specified font must be available on the viewers system to be shown in the browser.

The following shows the effects of setting font to absolute sizes:

size=1 size=2 size=3 size=4 size=5 size=6 size=7

BR

Used to force a line break. This is an empty element so the end tag is forbidden. The CLEAR attribute can be used to move down past floating images on either margin. <BR CLEAR=LEFT> moves down past floating images on the left margin, <BR CLEAR=RIGHT> does the same for floating images on the right margin, while <BR CLEAR=ALL> does the same for such images on both left and right margins.

MAP

The MAP element provides a mechanism for client-side image maps. These can be placed in the same document or grouped in a separate document although this isn't yet widely supported. The MAP element requires start and end tags. It contains one or more AREA elements that specify hotzones on the associated image and bind these hotzones to URLs.

Here is a simple example for a graphical navigational toolbar:

<img src="navbar.gif" border=0 usemap="#map1">

<map name="map1">
 <area href=guide.html alt="Access Guide" shape=rect coords="0,0,118,28">
 <area href=search.html alt="Search" shape=rect coords="184,0,276,28">
 <area href=shortcut.html alt="Go" shape=rect coords="118,0,184,28">
 <area href=top10.html alt="Top Ten" shape=rect coords="276,0,373,28">
</map>

The MAP element has one attribute NAME which is used to associate a name with a map. This is then used by the USEMAP attribute on the IMG element to reference the map via a URL fragment identifier. Note that the value of the NAME attribute is case sensitive.

The AREA element is an empty element and so the end tag is forbidden. It takes the following attributes: SHAPE, COORDS, HREF, NOHREF and ALT. The SHAPE and COORDS attributes define a region on the image. If the SHAPE attribute is omitted, SHAPE="RECT" is assumed.

shape=rect coords="left-x, top-y, right-x, bottom-y"

shape=circle coords="center-x, center-y, radius"

shape=poly coords="x1,y1, x2,y2, x3,y3, ..."

Where x and y are measured in pixels from the left/top of the associated image. If x and y values are given with a percent sign as a suffix, the values should be interpreted as percentages of the image's width and height, respectively. For example:

   SHAPE=RECT COORDS="0, 0, 50%, 100%"

The HREF attribute gives a URL for the target of the hypertext link. The NOHREF attribute is used when you want to define a region that doesn't act as a hotzone. This is useful when you want to cut a hole in an underlying region acting as a hotzone.

If two or more regions overlap, the region defined first in the map definition takes precedence over subsequent regions. This means that AREA elements with NOHREF should generally be placed before ones with the HREF attribute.

The ALT attribute is used to provide text labels which can be displayed in the status line as the mouse or other pointing device is moved over hotzones, or for constructing a textual menu for non-graphical Browsers. Authors are strongly recommended to provide meaningful ALT attributes to support interoperability with speech-based or text-only Browsers.




previous next contents