More HTML answers

by Danny
Published 2 min read

Use headings to describe the structure of a page, not to pick a font size. Learn how to order h1 to h6, why skipping levels confuses screen reader users, and how to style headings freely.

The short answer

#

Use one h1 for the page topic, h2 for the main sections, h3 for parts inside those, and so on. Do not skip levels on the way down, so no h1 straight to h3. Jumping back up any number of levels is fine. If you want a smaller heading, change its size with CSS rather than picking a lower level.


_10
<h1>Learning to bake bread</h1>
_10
_10
<h2>Equipment</h2>
_10
<h3>Ovens</h3>
_10
<h3>Proving baskets</h3>
_10
_10
<h2>Your first loaf</h2>

Why it happens

#

Headings are the main way many people find their way around a page. Screen reader users often open a list of headings or press a key to jump from one to the next, and the level tells them how the content is nested. When an h3 follows an h1 directly, it sounds like a section is missing, as if they skipped past an h2 by mistake.

Most skipped levels come from choosing headings by how they look. The default h3 is smaller than h2, so someone wanting a smaller title picks h3. The level should describe the structure; CSS should handle the size.

Skipping a level is not invalid HTML, and on its own it is not always a WCAG failure. Audit tools such as axe and Lighthouse still flag it as a best practice issue because it makes the page harder to navigate.

How to fix it

#

Plan the outline first

Write the headings out as a nested list before you build the page. Each heading should be one level below the section it belongs to.

  • h1: Learning to bake bread
    • h2: Equipment
      • h3: Ovens
      • h3: Proving baskets
    • h2: Your first loaf

Style headings with classes, not levels

Keep the right element and change the look separately.


_10
<h2 class="heading-small">Related posts</h2>


_10
.heading-small {
_10
font-size: 1rem;
_10
text-transform: uppercase;
_10
letter-spacing: 0.05em;
_10
}

Let components accept a heading level

A reusable card does not know where it will be placed. Let the parent pass the level in, so the same card can sit under an h2 on one page and an h3 on another.


_13
type CardProps = {
_13
title: string;
_13
level?: 2 | 3 | 4;
_13
};
_13
_13
export function Card({ title, level = 3 }: CardProps) {
_13
const Heading = `h${level}` as const;
_13
return (
_13
<div className="card">
_13
<Heading className="card-title">{title}</Heading>
_13
</div>
_13
);
_13
}

Stick to one h1

The HTML standard allows more than one h1, but a single h1 that matches the page topic is the clearest choice for both people and search engines. The old idea that each section or article restarts heading levels came from a document outline algorithm that browsers never implemented, and it has been removed from the standard.

Only use headings for headings

A heading should introduce content that follows it. Short pieces of text such as a promotional line, a price or "Sign up today" are usually better as a paragraph with a class.

Common pitfalls

#
  • Choosing h4 because it is the right size. Pick the level by structure and style it.
  • Faking headings with bold paragraphs, which leaves them out of the headings list entirely.
  • Forgetting the headings inside reusable components, which often hard-code a level that is wrong on some pages.
  • Leaving the page with no h1 because the logo or site name is in the header.
  • Using role="heading" and aria-level on a div when a real heading element would do the same job.
#

Was this resource helpful?