By WebNest Studio Engineering Team
HTML Tutorial
HTML Headings and Hierarchy
HTML provides six levels of headings, <h1> through <h6>, used to organize content into a logical outline — much like chapters and subheadings in a book. Headings are not a font-size shortcut; they are structural markers that describe how content is nested and related.
Getting heading hierarchy right matters more than most beginners expect: it directly affects how screen reader users navigate a page and how search engines interpret the relative importance of your content.
Why it matters
Headings are the outline of a page. Screen-reader users navigate by jumping from heading to heading, and search engines read them to work out what the page is about. Choosing a heading level because of its size, instead of its place in the outline, breaks both.
The h1–h6 Hierarchy
<h1> represents the most important heading on the page — typically the page's main title — and should generally appear only once per page. <h2> introduces major sections beneath it, <h3> introduces subsections within an <h2>, and so on down to <h6>. The numbers describe nesting depth, not visual size — although browsers do apply a default size that decreases as the number increases, that styling can and should be overridden with CSS rather than by picking a heading level for its default appearance.
Why Skipping Levels Hurts Accessibility and SEO
Screen reader users frequently navigate a page by jumping between headings, and many screen readers let users request only a specific level ("show me all h2s"). If a page jumps from an <h1> straight to an <h4> because the h4 "looked right" visually, that user loses the logical structure of the page. Search engines also use heading hierarchy to understand topic structure and relative importance, so skipped or disordered levels can weaken how well a page's content is understood and indexed.
- Never choose a heading level purely because of its default font size — style headings with CSS instead.
- Do not skip levels going down (h1 to h3 with no h2) just to reach a desired visual weight.
- Keep exactly one h1 per page representing its primary topic.
Example
A correctly nested heading outline for an article page
<h1>Complete Guide to HTML Headings</h1>
<h2>Why Headings Matter</h2>
<p>Headings create a navigable outline of your content.</p>
<h2>Heading Levels</h2>
<h3>h1 through h3</h3>
<p>Used for the main title and major sections.</p>
<h3>h4 through h6</h3>
<p>Used for deeper nested subsections.</p>
Renders a page with a large main title, two major section headings of decreasing size, and nested subsection headings — while also giving screen readers a clean, logically ordered outline to navigate.
Common Mistakes
- Using multiple <h1> elements on a single page instead of one clear primary heading.
- Skipping heading levels (e.g. h1 straight to h4) purely to get a smaller default font size.
- Choosing heading tags based on their visual appearance rather than the content's logical structure.
- Using bold or large text styled to look like a heading instead of an actual heading element, which hides the structure from assistive technology.
Exercise
The heading levels below were chosen for their size, and the outline makes no sense. Fix them so that there is one h1, the two main sections are h2, and the sub-section is h3.
Expected result: an outline of Python Course, then Basics (with Variables under it), then Projects.
<h3>Python Course</h3>
<h1>Basics</h1>
<p>Start here.</p>
<h4>Variables</h4>
<p>Names that refer to values.</p>
<h1>Projects</h1>
<p>Build something real.</p>
Show hints
- The title of the page is the single
h1. - A sub-section is one level below its parent section, so levels are never skipped on the way down.
Show solution
<h1>Python Course</h1>
<h2>Basics</h2>
<p>Start here.</p>
<h3>Variables</h3>
<p>Names that refer to values.</p>
<h2>Projects</h2>
<p>Build something real.</p>
Quick quiz
1. How many heading levels does HTML have?
- A. Four
- B. Six
- C. Five
- D. Unlimited
Show answer
B. They run from h1, the most important, to h6.
2. You want smaller heading text. What should you do?
- A. Use a lower heading level such as h4
- B. Use a bold paragraph
- C. Keep the correct level and change the size with CSS
- D. Use <small> around the page title
Show answer
C. The level states the place in the outline. Appearance is the job of CSS.
3. Which is the generally recommended number of h1 elements on a page?
- A. As many as possible for SEO
- B. One per paragraph
- C. None
- D. One, describing the page as a whole
Show answer
D. A single h1 gives the page one clear title.
Interview questions
Why should heading levels not be skipped?
Show answer
The levels form a nested outline. Going from an h2 straight to an h4 suggests that a level is missing, which confuses people who navigate by headings with a screen reader, since they rely on the levels to understand how sections relate. Moving back up, from an h4 to an h2 when a new section starts, is fine.
How do headings affect SEO?
Show answer
Search engines use headings to understand the topic and structure of a page, with the h1 carrying the most weight as the statement of what the page is about. Clear, descriptive headings also make content easier to scan, which keeps visitors on the page. Stuffing keywords into headings or using several competing h1 elements does not help.
Key Points to Remember
- Headings (h1–h6) describe document structure and nesting depth, not just visual size.
- Use exactly one h1 per page for the primary topic.
- Never skip heading levels — doing so breaks the logical outline for screen readers and SEO.
- Control heading appearance with CSS, not by picking a level for its default font size.
Practice in the playground
Write and run your own code for this topic, or start from the exercise or an example. Shows a live preview of your HTML, CSS and JavaScript. Your code for each topic is kept in this browser.
Run the examples
Change an input, predict the result, then compare it with the output. Explain why the result changes.
Written by
WebNest Studio Engineering Team
Practical lessons from developers working with Java, Python, React, databases and production systems.
Led by Vansh Duggal, Founder, WebNest Studio · Full-stack & software engineering