Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

H1, H2, H3, H4, H5, H6 - headings

Purpose

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

Typical rendering

In large font and in bold face, often separated with blank lines from the text. More important headings are generally rendered in a larger font than less important ones. H1 headings are often very large font, whereas H6 can be tiny (even smaller than normal text!).

Basic syntax

<Hn>heading text</Hn>

where n is 1, 2, 3, 4, 5, or 6.

Possible attributes (Not in HTML 2.0!)

attribute name possible values meaning notes
ALIGN LEFT, CENTER, RIGHT alignment of the heading deprecated in HTML 4.0

The default is left alignment, but this can be overridden by an enclosing DIV or CENTER element. (HTML 2.0, which has no ALIGN attribute, contained no explicit rule for default alignment. On the other hand, it described "typical renderings" presenting H1 as centered and other headings with different amounts of left indentation.)

Allowed context

Block container.

Contents

Text elements.

Examples

Example H-1.html:

<H1>Notes on General Relativity</H1>

Example H-2.html:

<H1 ALIGN=CENTER>The story of my life</H1>
<H2>Preface</H2>
<H3>General remarks</H3>

There is a separate file which contains headings of all levels.

Notes

Documents should not skip heading levels, e.g. from H1 to H3 without intervening H2. This rule is not enforced by the formal syntax of HTML, but it has always been the recommended practice.

Avoid using H5 and H6 at all. More than four levels of headings are rarely needed, and popular browsers may display H5 and H6 in a manner which is less prominent than normal text!

See general structure recommendations for a detailed suggestion on heading usage.

In particular, don't use e.g. H5 or H6 to cause text to be presented in a small font just because some browsers present them so. Other browsers - or even future versions of those browsers - may well adopt the more reasonable view that even the lowest level headings should be presented at least as prominently as normal text. If small font is what you really want, use the SMALL (or FONT) element.

Since heading elements are intended to be presented prominently by a browser, don't make them very long. Normally you should not try to add anything to the presentation by using text markup within the heading text. It is the job of a browser to present headings as headings. And for the same reason you should not write a heading in all upper case.

It might be a good idea to make every heading an anchor, i.e. a possible target of a link. Use the A element with NAME attribute for this. Example:
<H2><A NAME="intro">Introduction</A></H2>
Other people (or you) may then link to specific sections in your document, not just to the document as a whole. Notice that you must put the A element within the heading element, not vice versa.



Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.