h1 - h6 Elements


 

Module

The h1 - h6 elements are declared by the XHTML 1.1 Text Module (Block Phrasal)

Elements in the Text Module are:
span | br (Inline Structural Support Module)
em | strong | q | cite | abbr | acronym | code | var | kbd | samp | dfn (Inline Phrasal Support Module)
div | p (Block Structural Support Module)
h1 - h6 | blockquote | pre | address (Block Phrasal Support Module)

Description

The elements h1 to h6 represent a series of headings, from the most important (h1) to least important (h6). They are usually rendered by a graphical browser in bold type and in a font size which decreases as the headings get less important, but obviously CSS can be used to set specific styles for each heading.

Headings are block level elements and cannot therefore be contained within, for example, paragraphs (denoted by the p element) or hyperlinks (the a element).

A document usually has a main h1 title as its first heading and then the lower levels of heading are used to subdivide the content into logical subsections. Headings should not be used merely to increase the size of a section of text which is not a heading and also a particular heading level should never be chosen simply because your particular browser renders that heading in the desired font size.

h2 elements should be used to indicate subsections of content headed by an h1. Similarly, h3 elements should be used for subsections of content headed by an h2 and so on. CSS can take care of the presentational issues later. Personally, I have found that, by following these rules, I have never needed to use h5 or h6 elements and only rarely use h4. I find that documents which logically require 5 or 6 levels of heading are usually better structured into several smaller documents.

This example shows the six levels of heading:

<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h6>Heading Level 6</h6>

This renders as:

Heading Level 1

Heading Level 2

Heading Level 3

Heading Level 4

Heading Level 5
Heading Level 6

No styling has been applied to any of the six headings rendered above, so they are displayed using your browser's default styles.

#REQUIRED Attributes

There are no #REQUIRED attributes on the h1 - h6 elements.


Specific Attributes

There are no specific attributes declared on the h1 - h6 elements.


Common Attributes

Common attributes of the h1 - h6 elements are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the h1 - h6 elements is:

( #PCDATA | Inline.mix )*

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of h1 - h6

Valid parents of h1 - h6


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > h1 - h6 Elements