| Content categories | Flow content, heading content, palpable content. |
|---|---|
| Permitted content | Phrasing content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents | Any element that accepts flow content; don't use a heading element as a child of the <hgroup> element — it is now deprecated. |
| Permitted ARIA roles |
tab, presentation
|
| DOM interface | HTMLHeadingElement |
These elements include the global attributes.
The align attribute is obsolete; don't use it.
font-size property instead.<h1>, next use <h2> and so on.<h1> more than once on a page. See Defining sections in Using HTML sections and outlines for more information.The following code shows all the heading levels, in use.
<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>
Here is the result of this code:
The following code shows a few headings with some content under them.
<h1>Heading elements</h1> <h2>Summary</h2> <p>Some text here...</p> <h2>Examples</h2> <h3>Example 1</h3> <p>Some text here...</p> <h3>Example 2</h3> <p>Some text here...</p> <h2>See also</h2> <p>Some text here...</p>
Here is the result of this code:
A common navigation technique for users of screen reading software is jumping from heading to heading to quickly determine the content of the page. Because of this, it is important to not skip one or more heading levels. Doing so may create confusion, as the person navigating this way may be left wondering where the missing heading is.
<h1>Heading level 1</h1> <h3>Heading level 3</h3> <h4>Heading level 4</h4>
<h1>Heading level 1</h1> <h2>Heading level 2</h2> <h3>Heading level 3</h3>
Headings may be nested as subsections to reflect the organization of the content of the page. Most screen readers can also generate an ordered list of all the headings on a page, which can help a person quickly determine the hierarchy of the content:
h1 Beetles h2 Etymologyh2 Distribution and Diversityh2 Evolution h3 Late Paleozoich3 Jurassich3 Cretaceoush3 Cenozoich2 External Morphology h3 Head h4 Mouthpartsh3 Thorax h4 Prothoraxh4 Pterothoraxh3 Legsh3 Wingsh3 AbdomenWhen headings are nested, heading levels may be "skipped" when closing a subsection.
Another common navigation technique for users of screen reading software is to generate a list of sectioning content and use it to determine the page's layout.
Sectioning content can be labeled using a combination of the aria-labelledby and id attributes, with the label concisely describing the purpose of the section. This technique is useful for situations where there is more than one sectioning element on the same page.
<header>
<nav aria-labelledby="primary-navigation">
<h2 id="primary-navigation">Primary navigation</h2>
<!-- navigation items -->
</nav>
</header>
<!-- page content -->
<footer>
<nav aria-labelledby="footer-navigation">
<h2 id="footer-navigation">Footer navigation</h2>
<!-- navigation items -->
</nav>
</footer>
In this example, screen reading technology would announce that there are two <nav> sections, one called "Primary navigation" and one called "Footer navigation". If labels were not provided, the person using screen reading software may have to investigate each nav element's contents to determine their purpose.
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. | Living Standard | |
| HTML5 The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. | Recommendation | |
| HTML 4.01 Specification The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. | Recommendation |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements