Skip to content
Tutorials Center
My learning

Topics

HTML Reference · Sections

The <h1>–<h6> elements

Reference for the HTML heading elements <h1> to <h6>: heading levels and page structure, accessibility, common mistakes, examples and technical details.

The heading elements <h1>, <h2>, <h3>, <h4>, <h5> and <h6> give titles to the parts of a document. The number is the rank: <h1> is the top level, usually the page's main title, and each lower level introduces a subsection of the heading above it. Together they form the document's outline.

HTML
<h1>Visiting the Botanical Garden</h1>
<h2>Opening hours</h2>
<h2>Getting here</h2>
<h3>By bus</h3>
<h3>By bike</h3>

Try it

Heading levels and the outline they create

Attributes

These elements have no attributes of their own. They accept the global attributes. The old align attribute is obsolete; use CSS text-align.

Usage notes

  • One <h1> per page is the safe default. It should describe the page as a whole, usually matching the <title> closely. Multiple <h1>s are not invalid, but a single one keeps the structure clear for everyone.
  • Don't skip levels going down. After an <h2>, the next deeper heading should be an <h3>, not an <h4>. Jumping back up any number of levels (from <h4> to <h2>) is fine.
  • Choose by structure, not size. Pick the level that matches the hierarchy, then set the size with CSS. Never pick <h4> just because it looks smaller.
  • Bold text is not a heading. A <p> with <strong> looks like a heading but doesn't appear in the outline. Conversely, don't use a heading for text that isn't a section title, like a tagline; see <hgroup>.
  • Accessibility. Headings are the most common way screen reader users navigate: they list them or jump from one to the next. Each heading is exposed with the heading role and its level (1–6).
  • Sectioning elements don't change levels. Wrapping an <h1> in an <article> or <section> does not turn it into a lower level for assistive technology. Older browser styles shrank such nested <h1>s, and browsers are removing that rule, so use the correct level and set sizes yourself.
  • Linkable headings. Give a heading an id so other pages can link straight to it, as explained in Link Targets and Page Jumps.

Technical summary

Content categories Flow content, heading content, palpable content
Permitted content Phrasing content
Tag omission None; both the start and end tags are required
Permitted parents An <hgroup> element; any element that accepts flow content
Implicit ARIA role heading, with aria-level equal to the number (1–6)
DOM interface HTMLHeadingElement
Default display block, bold, with sizes decreasing from <h1> (2em) to <h6> (0.67em)

Browser support

Supported in every browser.