HTML 3.2 Features At a Glance


The Structure of HTML 3.2 Documents

Every HTML 3.2 document begins with the following <!DOCTYPE> declaration (to distinguish HTML 3.2 from other versions of HTML), followed by HEAD and BODY elements. The TITLE tags are required. All other tags are optional.

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

Note that in practice, many documents don't contain a <!DOCTYPE> declaration. This makes it difficult for browsers, validation tools, and other software to determine the version of HTML used in the document.

The HEAD element

This contains the document head, but you can always omit both the start and end tags for HEAD. The following elements belong to the document head:

TITLE defines the document title, and is always needed.
ISINDEX for simple keyword searches, see PROMPT attribute.
BASE defines absolute URL for resolving relative URLs.
STYLE reserved for future use with style sheets.
SCRIPT reserved for future use with scripting languages.
META used to supply meta info as name/value pairs.
LINK used to define relationships with other documents.

TITLE, STYLE and SCRIPT are containers and requires both start and end tags. The other elements are not containers so that end tags are forbidden. Note that conforming browsers won't render the contents of STYLE and SCRIPT elements.

The BODY element

This contains the document body. Both start and end tags for BODY may be omitted. 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. Colors are given in RGB as hexadecimal numbers (e.g. "#C0FFC0") or as one of 16 widely understood color names:

   aqua, black, blue, fuchsia, gray, green, lime, maroon,
   navy, olive, purple, red, silver, teal, white, and yellow

These colors were originally picked as being the standard 16 colors supported with the Windows VGA palette.

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 APPLET (embedded objects) 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

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 ALIGN attribute to set the text alignment within a heading, e.g.

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

ADDRESS

The ADDRESS element is used for information about the author of the document. It requires start and end tags.

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 groups related elements together and can be 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.
ISINDEX primitive HTML forms
Not a container, so the end tag is forbidden. This predates FORM and is used for simple kinds of forms which have a single text input field, implied by this element.
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, ALIGN, BORDER, CELLSPACING and CELLPADDING.


Lists

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

Unordered lists take the form:

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

The TYPE attribute can be used to set the bullet style on UL and LI elements.

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. You can reset it later on with the VALUE attribute on LI elements.

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.


Tables

These take the general form:

  <TABLE BORDER=3 CELLSPACING=2 CELLPADDING=2 WIDTH="80%">
  <CAPTION ALIGN=bottom> ... table caption ... </CAPTION>
  <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. The ALIGN attribute can be used to position the table to the LEFT, CENTER or RIGHT. The CAPTION element is used for captions. These are rendered at the top or bottom of the table depending on the optional ALIGN attribute.

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.


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>.
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
DFN defining instance of the enclosed term
CODE used for extracts from program code
SAMP used for sample output from programs, and scripts etc.
KBD used for text to be typed by the user
VAR used for variables or arguments to commands
CITE used for citations or references to other sources

Form fields

INPUT, SELECT and TEXTAREA

INPUT elements are not containers and so the end tag is forbidden. 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 require start and end tags and contain one or more OPTION elements. SELECT elements are used for single or multi-selection menus. TEXTAREA elements require start and end tags, and are used to define multi-line text fields. The content of the element is used to initialize the field.

Special Text level Elements

Anchors, IMG, APPLET, FONT, BR and MAP.

The A (anchor) element

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="kamasutra.html">happiness</a>.

The attributes are: NAME, HREF, REL, REV and TITLE. HREF is used to supply a URL identifying the linked document or image etc. 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. Anchors can't be nested.

IMG

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

Used to insert images. This is an empty element and so the end tag is forbidden. The attributes are: SRC, ALT, ALIGN, WIDTH, HEIGHT, BORDER, HSPACE, VSPACE, USEMAP and ISMAP. 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.

APPLET

Requires start and end tags. This element is supported by all Java enabled browsers. It allows you to embed a Java applet into HTML documents, e.g. to include an animation. The contents of the element are used as a fallback if the applet can't be loaded. The attributes are: CODE, CODEBASE, NAME, ALT, ALIGN, WIDTH, HEIGHT, HSPACE and VSPACE. APPLET uses associated PARAM elements to pass parameters to the applet.

FONT

Requires start and end tags. This allows you to change the font size and/or color for the enclosed text. The attributes are: SIZE, COLOR. Colors are given as RGB in hexadecimal notation or as one of 16 widely understood color names.

BR

Used to force a line break. This is an empty element and so the end tag is forbidden. The CLEAR attribute can be used to move down past floating images on either margin, e.g. <BR CLEAR=LEFT>.

MAP

Requires start and end tags. This allows you to define client-side image maps. MAP elements contain one or more AREA elements that specify hotzones on the associated image and bind these hotzones to URLs.


Amir Hekmatpour - Web Publishing Home Page