h1 (html element)

The h1 element is used to indicate the most important (or highest-level) heading on the page.

In total, we have six heading levels to choose from—h1 to h6—to add structure to the web page. h1 is the highest heading level (and, by default, the largest in terms of font size) and h6 the lowest (and smallest).

A document’s first heading should be an h1, followed by one or more h2 headings; each of these h2 headings can then have a further series of h3 headings below them, and so on, right on down to heading level 6. The HTML 4 spec states that heading levels should not be skipped (that is, you shouldn’t have a series of headings in the order h1, h2, h2, h4, which skips the h3 entirely), although it isn’t always possible to guarantee such rigidity in the markup, particularly if your pages are generated by a CMS. However, this goal is certainly one for which you should aim.

Headings add semantic richness to a document, which can help with search engines’ understanding of the makeup of that document, and provide users of assistive devices (such as screen readers) with an additional—and quick—method by which to navigate through a document: they can skip from heading to heading.

Figure 1 shows a comparison of the six heading levels in a fictional web site, as rendered by Firefox’s default browser style sheet.

headings-1-6

The document outline, showing the heading levels, is clear to see using Firefox’s Web Developer extension (via that tool’s Information > View Document Outline command), as shown in Figure 2.

heading-document-outline

Example

This h1 element
is used to present a fluffy welcome message:

<h1>Welcome to OmniUberMegaCorp's Web Site</h1>

Use This For …

This element may contain any text content, but it can’t include any block-level elements: only inline or phrase elements can be included.

Learn HTML5 Online

Get all SitePoint books and courses with a Learnable membership. Start building future-proof websites that are faster, more powerful, and easier to maintain.

No Reader comments

Comments on this post are closed.