A cheat sheet for web design students. Learn why every page needs a single h1, how the six heading levels build a logical content outline, and why heading levels are only ever used for structure, never for size.
The short version
Use one h1 per page, then work down one level at a time, with h2 under h1 and h3 under h2. Never skip a level, and never choose a heading for the size of its text.
h1 Page title
h2 Section
h3 Subsection
h2 Next sectionOn this cheat sheet
The h1 element
Every page needs one h1, and only one
The h1 is the top-level heading. It states what this page is about, in the same way that a book has a single title on its cover, and every web page should have exactly one.
Clear purpose. A page with one title has one job. If you find you need several h1 elements, you probably need several pages.
Accessibility. Screen reader users often press a key to jump straight to the h1 to find out what the page is about. If there are several, they can’t tell which is the real title.
Search engines. The h1 is a strong signal of the page’s main topic.
A solid root for the outline. Every other heading hangs from the h1 (see section 3).
A note on accuracy. The HTML specification doesn’t actually forbid more than one h1. A promised “outline algorithm” that would have let you reuse h1 inside sections was never implemented by browsers, so the dependable approach, and the rule we use on this course, is one h1 per page.
The h1 and the title element are different things
<title>
<h1>
Where it lives
In the <head>
In the <body>, inside <main>
Where people see it
Browser tab, bookmarks, search results
At the top of the page content
Typical form
Page topic, then site name
The page topic only
Example
Coffee menu | Hill Café
Coffee menu
They should agree about the topic of the page, but they don’t need to be identical, word for word.
The h1 and SEO
Write an h1 that says what the page is about
Search engines read the text of the h1 to understand what a page is about. There’s no secret ranking trick here. The aim is simply to describe the page clearly, to people and to search engines at the same time.
Be descriptive. Say what the page contains, using the words that people would search for.
Put the main topic first, and use the keyword naturally, once. Don’t stuff it in repeatedly.
Make it unique. No two pages on your site should have the same h1.
Keep it short. Anything from a few words up to one short line is fine.
Use real text. Don’t use an image for the h1, but if you must, give the image meaningful alt text.
Don’t use the site name on every page. Your logo and site name belong in the header, while the h1 names this particular page.
Weak h1
Why
Better h1
Welcome
Says nothing about the content
Hill Café: coffee and cake in Leeds
Hill Café (on every page)
Not unique, doesn’t describe the page
Our coffee menu
Coffee coffee best coffee cheap coffee
Keyword stuffing
Freshly roasted coffee
Click here to find out more about our services
Long and vague
Catering services
Building a content outline with headings
The six levels
HTML has six heading levels, h1 to h6. The number represents the heading’s rank in the hierarchy, where 1 is the most important. It is not a font size.
Level
Role
Use
h1
Title of the page
Exactly one
h2
Main sections of the page
As many as needed
h3
Subsections of an h2
As needed
h4 to h6
Further subdivisions
Rare. If you reach h5, consider splitting the page.
Think of a table of contents
Headings form an outline of your page, much like the contents page of a book, with its chapters, sections and subsections. Here’s a good test. If you removed everything except the headings, would what remains read as a sensible summary of the page?
h1 Coffee menu
├── h2 Hot drinks
│ ├── h3 Espresso-based
│ └── h3 Filter and brewed
├── h2 Cold drinks
│ ├── h3 Iced coffee
│ └── h3 Smoothies
└── h2 Allergy information
The indentation here is only used to show the hierarchy. In your real files, each heading will be followed by paragraphs and other content.
The logic: go down one level at a time
Each heading is the child of the nearest heading above it with a higher rank. That means the next heading can do one of three things:
Go one level deeper (h2 then h3) to start a subsection.
Stay at the same level (h3 then h3) to start a sibling.
Go back up by any number of levels (h4 then h2) to close subsections and begin a new section.
What it must never do is skip a level on the way down. An h3 straight after an h1 would be a subsection of a section that doesn’t exist, and that breaks the hierarchy.
After this heading…
Go deeper to
Stay at
Go back up to
h1
h2 only
None (no second h1)
–
h2
h3
h2
–
h3
h4
h3
h2
h4
h5
h4
h3 or h2
h5
h6
h5
h4, h3 or h2
h6
–
h6
h5 down to h2
Valid orderh1
h2
h3
h3
h2
h3
h4
h2
Broken orderh1
h3 ← skips h2
h2
h4 ← skips h3
h2 ← before the h1
h1 ← a second h1
Make each heading meaningful on its own. Users who list the headings on a page should be able to tell what each section covers. “More information” is a weak heading, whereas “Delivery and returns” is clear.
Every heading introduces content. Never add an empty heading just to create some space.
Don’t use a heading for text that isn’t one. A phone number, a quote or a slogan is not a heading.
Only add a subheading level if you’ll have at least two subheadings. A lone h3 under an h2 is usually a sign that the structure needs rethinking.
Plan the outline first. Write the headings as a list and check the hierarchy before you add any content.
Semantics, not size
Heading levels describe structure, not appearance
Browsers display h1 large and h6 small by default, so beginners are often tempted to choose a heading level for the size they want. This is known as presentational markup, and it’s wrong. The heading level must reflect where the heading sits in the hierarchy, and setting its size is the job of CSS.
Do: choose the level by structure, set the size in CSS<h2 class="small-heading">Allergy information</h2>
.small-heading {
font-size: 1.1rem;
}
Don’t: pick the level by size<h1>Coffee menu</h1>
<h4>Allergy information</h4>
<!-- h4 chosen because it's smaller -->
Do: use a real heading<h2>Opening times</h2>
Don’t: fake a heading with styling<p><strong>Opening times</strong></p>
<div class="heading">Opening times</div>
<h1 style="font-size:12px">Opening times</h1>
Two mistakes, one principle. Don’t use a heading element just to get big or small text, and don’t use bold p, div or span elements to make text look like a heading. In either case, the structure that assistive technologies and search engines read no longer matches what the page shows.
Quick check: choosing between a heading and styled text
Question
If yes
Does this text introduce a section of content?
Use a heading, and pick the level from the outline
Do I just want it to look big or bold?
Use CSS on a suitable element (p, span)
Do I want a smaller or larger heading than the default?
Keep the correct level and change its size with CSS
Where headings sit in the document
Headings work inside a semantic page structure
Headings organise the content, while structural elements organise the page. Together, they give assistive technologies both a map of the page (the landmarks) and a table of contents (the headings).
Element
Purpose
<header>
Introductory content: logo, site name, tagline
<nav>
A block of main navigation links
<main>
The unique content of this page. Use one per page. The h1 goes here.
<section>
A themed group of content, normally introduced by a heading
<article>
A self-contained item, such as a blog post
<aside>
Related but secondary content, such as a sidebar
<footer>
Closing content: contact details, copyright
<body>
<header>
<p>Hill Café</p> <!-- site name: not an h1 -->
<nav>…</nav>
</header>
<main>
<h1>Coffee menu</h1> <!-- the one h1 -->
<section>
<h2>Hot drinks</h2>
<p>…</p>
<h3>Espresso-based</h3>
<p>…</p>
</section>
<section>
<h2>Cold drinks</h2>
<p>…</p>
</section>
</main>
<footer>…</footer>
</body>
Heading levels don’t restart inside a section or article. Keep counting down through a single, page-wide outline, so an h2 inside a section still means “the second level of the page”.
Common mistakes at a glance
Mistake
Fix
No h1 on the page
Add one that names the page
Several h1 elements
Keep one, and demote the others to h2 where they are sections
Tip: browser extensions such as HeadingsMap, or the W3C Markup Validator, can show you the heading outline of any page, so you can check its hierarchy at a glance.