Headings (2024)

Permitted Context: %Body.Content
Content Model: %text

HTML defines six levels of headings. A heading element implies allthe font changes, paragraph breaks before and after, and any whitespace necessary to render the heading. The heading elements are H1, H2,H3, H4, H5, and H6 with H1 being the highest (or most important) leveland H6 the least. For example:

<H1>This is a top level heading</H1> Here is some text.<H2>Second level heading</H2> Here is some more text.

Use the DIV element together with header elements when you want tomake the hierarchical structure of a document explicit. This is neededas header elements themselves only contain the text of the header, anddo not imply any structural division of documents into sections. Headerelements have the same content model as paragraphs, that is text andcharacter level markup, such as character emphasis, inline images, formfields and math.

Headers play a related role to lists in structuring documents, andit is common to number headers or to include a graphic that acts like abullet in lists. HTML 3.0 recognizes this with attributes that assistwith numbering headers and allow authors to specify a custom graphic.

The numbering style is controlled by the style sheet, e.g.

  1. The style sheet specifies whether headers are numbered, andwhich style is used to render the current sequence number, e.g. arabic,upper alpha, lower alpha, upper roman, lower roman or a numberingscheme appropriate to the current language.
  2. Whether the parent numbering is inherited, e.g. "5.1.d" where 5 isthe current sequence number for H1 headers, 1 is the number for H2headers and 4 for H3 headers.

The seqnum and skip attributes can be used tooverride the default treatment of header sequence numbers, and providefor a continuity with numbered lists.

The dingbat or src attribute may be used tospecify a bullet-like graphic to be placed adjacent to the header. Thepositioning of this graphic is controlled by the style sheet. Thegraphic is for decorative purposes only and silently ignored onnon-graphical HTML user agents.

Word Wrapping

User agents are free to wrap lines at whitespace characters so as toensure lines fit within the current window size. Use the &nbsp;entity for the non-breaking space character, when you wantto make sure that a line isn't broken! Alternatively, use the NOWRAPattribute to disable word wrapping and the <BR> element to forceline breaks where desired.

Netscape includes two tags: <NOBR>...</NOBR>, and<WBR>. The former turns off wordwrapping between the start andend NOBR tag, while WBR is for the rare case when you want to specifywhere to break the line if needed. Should HTML 3.0 provide anequivalent mechanism to WBR, (either a tag or an entity)?

Permitted Attributes

ID
An SGML identifier used as the target for hypertextlinks or for naming particular elements in associated style sheets.Identifiers are NAME tokens and must be unique within the scope of thecurrent document.
LANG
This is one of the ISO standard language abbreviations,e.g. "en.uk" for the variation of English spoken in the United Kingdom.It can be used by parsers to select language specific choices forquotation marks, ligatures and hypenation rules etc. The languageattribute is composed from the two letter language code from ISO 639,optionally followed by a period and a two letter country code from ISO3166.
CLASS
This a space separated list of SGML NAME tokens and isused to subclass tag names. For instance, <H2 CLASS=Section>defines a level 2 header that acts as a section header. By convention,the class names are interpreted hierarchically, with the most generalclass on the left and the most specific on the right, where classes areseparated by a period. The CLASS attribute is most commonly used toattach a different style to some element, but it is recommended thatwhere practical class names should be picked on the basis of theelement's semantics, as this will permit other uses, such asrestricting search through documents by matching on element classnames. The conventions for choosing class names are outside the scopeof this specification.
ALIGN
Headings are usually rendered flush left. The ALIGNattribute can be used to explicitly specify the horizontalalignment:
align=left
The heading is rendered flush left (thedefault).
align=center
The heading is centered.
align=right
The heading is rendered flush right.
align=justify
Heading lines are justified wherepractical, otherwise this gives the same effect as the defaultalign=left setting.

For example:

<h1 align=center>This is a centered heading</H1>Here is some text. <H2 align=right>and this is a flush rightheading</H2> Here is some more text.
CLEAR
This attribute is common to all block-like elements. Whentext flows around a figure or table in the margin, you sometimes wantto start an element like a header, paragraph or list below the figurerather than alongside it. The CLEAR attribute allows you to move downunconditionally:
clear=left
move down until left margin is clear
clear=right
move down until right margin is clear
clear=all
move down until both margins are clear

Alternatively, you can decide to place the element alongside thefigure just so long as there is enough room. The minimum width neededis specified as:

clear="40 en"
move down until there is at least 40 en units free
clear="100 pixels"
move down until there is at least 100 pixelsfree

The style sheet (or browser defaults) may provide default minimumwidths for each class of block-like elements.

SEQNUM
A sequence number is associated with each level ofheader from the top level (H1) to the bottom level (H6). This attributeis used to set the sequence number associated with the header level ofthe current element to a given number, e.g. SEQNUM=10. Normally, thesequence number is initialized to 1 at the beginning of the documentand incremented after each header element. It is reset to 1 by anyheader element of a higher level, e.g. an H1 header resets the sequencenumbers for H2 to H6. The style of header numbering is controlled bythe style sheet.
SKIP
Increments the sequence number before rendering theelement. It is used when headers have been left out of the sequence.For instance, SKIP=3 advances the sequence number past 3 omitted items.
DINGBAT
Specifies an iconic image to appear preceding theheader. The icon is specified as an entity name. A list of standardicon entity names for HTML 3.0 is given in an appendix of thisspecification.
SRC
Specifies an image to appear preceding the header. Theimage is specified as a URI. This attribute may appear together withthe MD attribute.
MD
Specifies a message digest or cryptographic checksum for theassociated graphic specified by the SRC attribute. It is used when youwant to be sure that a linked object is indeed the same one that theauthor intended, and hasn't been modified in any way. For instance,MD="md5:jV2OfH+nnXHU8bnkPAad/mSQlTDZ", which specifies an MD5 checksumencoded as a base64 character string. The MD attribute is generallyallowed for all elements which support URI based links.
NOWRAP
The NOWRAP attribute is used when you don't want thebrowser to automatically wrap lines. You can then explicitly specifyline breaks in headings using the BR element. For example:
<h1 nowrap>This heading has wordwrap turned off<br>and the BR element is used for explicit line breaks</H1>
Headings (2024)
Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6071

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.