HTML has six heading elements, <h1> to <h6>, and the number is the level. <h1> is the top level, normally the page's main title. <h2> marks the main sections, <h3> the parts inside a section, and so on down to <h6>.
<h1>How to make cold brew coffee</h1>
<h2>What you need</h2>
<h2>Steps</h2>
<h3>Grind the beans</h3>
<h3>Steep overnight</h3>
<h2>How to store it</h2>
The indents are only there to show the levels. What counts is the number in each tag: together, the headings form an outline of the page.
Who reads your headings
Three kinds of readers use that outline:
- People who scan. Visitors skim the headings to decide which part to read. Google's SEO starter guide recommends breaking long content into sections with headings for exactly this reason.
- People using screen readers. A common way to move through a page is to jump from heading to heading, or to pull up a list of all headings. A clear outline lets them find their part fast.
- Search engines. Google uses heading elements, such as
<h1>, among the sources for the title link it shows in results. Browsers and tools can also build a table of contents from headings.
What Google says about H1s, order and numbers
Google's guidance is more relaxed than many SEO checklists:
- Order. Headings in semantic order are "fantastic for screen readers", Google says, but for Google Search it doesn't matter if they're out of order.
- How many. There's no ideal number of headings. Google adds: if you think it's too much, it probably is. Google SEO starter guide
- The main heading. If a page has several large, prominent headings, Google may use the first one for the title link. So make your main title stand out, for example as the first visible
<h1>. Google title links
The HTML standard allows more than one <h1> as long as they aren't nested, but MDN recommends one per page. If you learned that each <section> may start with its own <h1>, that advice is outdated: nesting <h1>s inside sectioning elements is no longer valid HTML.
How to write good headings
- Give the page one
<h1>that says what it's about. Like the<title>, it names the topic, in words a visitor would use. - Make each heading describe its section. Accessibility guidelines ask for headings that describe the topic or purpose (WCAG 2.4.6, Level AA). "Steps" is fine in a recipe; "More info" tells nobody anything.
- Don't skip levels. Go from
<h2>to<h3>, not<h2>to<h4>. Someone jumping through headings may think they missed a section. - Use headings for structure, not looks. If text should be big or bold, change it with CSS. If a heading looks too large, restyle it rather than picking a lower level.
- Use your keywords where they fit naturally. A heading that matches the words people search helps them see they're in the right place. Stuffing keywords into headings is keyword stuffing, which breaks Google's spam policies.
Common heading problems
These show up on many sites, often from a theme or page builder rather than from the writer:
- No
<h1>, or the logo as the<h1>. The page's real title is then a<div>or a lower heading. - Headings used for styling. A tagline, a widget title or a bold sentence marked as
<h2>adds noise to the outline. - Skipped levels. A section jumps from
<h2>straight to<h4>because the designer liked that size. - Empty or duplicate headings. Several sections called "Overview" leave screen reader users guessing.
To see a page's outline, list its headings in the browser. Open the developer console and run:
document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(h => console.log(h.tagName, h.textContent.trim()));
Read the output as a table of contents. If it makes sense on its own, your headings are doing their job. For headings in the wider picture of page optimization, see on-page SEO.