Skip to content
El Joseo
SEO for Google

H tags in SEO

H tags (H1 to H6) explained with code examples: how headings work in HTML and how to use them for SEO. Includes an interactive tester.

Share
Code editor screen showing an h1 tag inside a page's HTML
Article summary

H tags (H1 to H6) are the HTML elements that give a page its titles and hierarchy. The first part of the guide explains how they work in code, with examples you can read side by side with how they look, and an interactive tester.

The second part covers SEO: one clear H1, H2 and H3 with natural keywords, no skipped levels, and the difference between the H1 and the meta title.

H tags (heading tags, from <h1> to <h6>) are the HTML elements that mark the titles and subtitles of a page. This guide has two parts: first, how headings work in HTML (useful for any web developer, with code you can read and test), and then how to use them for SEO. The reference for the element is MDN.

Part 1: H tags in HTML (for web developers)

Forget SEO for a minute. This is what a heading is, in plain HTML.

The six levels

HTML has six heading levels. The browser draws each one a bit smaller than the last, but the level is about importance, not size.

HTML code

<h1>H1</h1>
<h2>H2</h2>
<h3>H3</h3>
<h4>H4</h4>
<h5>H5</h5>
<h6>H6</h6>

How it looks

H1

H2

H3

H4

H5

H6

TagLevelTypical use
<h1>1Main title of the page
<h2>2Main sections
<h3>3Subsections of an H2
<h4>–<h6>4–6Deeper levels, rarely needed

Hierarchy: like the chapters of a book

Headings nest. An H2 lives inside an H1, an H3 inside an H2, and so on. Here is the classic outline:

HTML code

<h1>Modes of transportation</h1>
  <h2>Vehicles</h2>
    <h3>Manual</h3>
    <h3>Automatic</h3>
      <h4>Nissan</h4>

How it looks

Modes of transportation

Vehicles

Manual

Automatic

Nissan

Keep it logical: don’t talk about dogs in your H1 and cats in your H2. Talk about dogs in the H1 and, say, one dog breed in the H2.

A real example

This is how it works in my article What is the meta title tag and what is it for?: the H1 holds the main topic and the H2 opens a subtopic.

HTML code

<h1>What is the meta title tag and what is it for?</h1>
<p>...</p>
<h2>How do we change the meta title of a URL?</h2>
<p>...</p>

How it looks

What is the meta title tag and what is it for?

Intro text of the article...

How do we change the meta title of a URL?

Steps to change it...

The H1 contains the keywords I want to rank for. It tells Google: “this is the main topic of my article.”

Meaning first, size second

Choose the tag for its meaning, then change how it looks with CSS. Never pick an <h4> because you like its size.

✕ Wrong

<h4 style="font-size:2rem">Coffee guide</h4>
<h1 style="font-size:1rem">Everything you need</h1>

Coffee guide

Everything you need

The levels are upside down: the biggest title is an H4 and the small subtitle is the H1.

✓ Right

<h1 class="big">Coffee guide</h1>
<h2 class="small">Everything you need</h2>

Coffee guide

Everything you need

Right level for each role, and CSS (.big, .small) handles the look.

Headings inside page sections

Headings work together with semantic containers like <main>, <article> and <section>: each section gets its own heading.

HTML code

<main>
  <h1>Coffee guide</h1>
  <p>Intro...</p>
  <section>
    <h2>Origins</h2>
    <p>...</p>
  </section>
  <section>
    <h2>Brewing</h2>
    <p>...</p>
  </section>
</main>

How it looks

Coffee guide

Intro...

Origins

Text about origins...

Brewing

Text about brewing...

Accessibility: what a screen reader hears

Screen reader users often jump from heading to heading to skim a page. Good headings are their table of contents. The W3C Web Accessibility Initiative recommends headings that reflect the page structure.

HTML code

<h1>Coffee guide</h1>
<h2>Origins</h2>
<h2>Brewing</h2>
<h3>Espresso</h3>

How it looks

What a screen reader lists

1. H1 Coffee guide

  2. H2 Origins

  2. H2 Brewing

    3. H3 Espresso

Common mistakes

Three mistakes I see all the time, each with its fix.

1. Skipping levels

✕ Wrong

<h1>Coffee guide</h1>
<h4>Ingredients</h4>
<h2>Steps</h2>

Coffee guide

Ingredients

Steps

It jumps from H1 to H4. The outline has a hole.

✓ Right

<h1>Coffee guide</h1>
<h2>Ingredients</h2>
<h2>Steps</h2>

Coffee guide

Ingredients

Steps

H1 → H2 → H2. No levels skipped.

2. Fake headings made with styles

✕ Wrong

<p style="font-size:2rem;font-weight:bold">Coffee guide</p>

Coffee guide

It looks like a title, but for the browser it is just a paragraph.

✓ Right

<h1>Coffee guide</h1>

Coffee guide

A real H1 that can be styled however you like.

3. Headings for things that are not titles

✕ Wrong

<h2>Menu</h2>
<h2>Login</h2>
<h2></h2>

Menu

Login

 

"Menu" and "Login" are not sections of the content, and the last one is empty.

✓ Right

<nav aria-label="Menu">
  <a href="/">Home</a>
</nav>
<h2>Ingredients</h2>

Home

Ingredients

Use

Try it yourself

Edit the code, load a preset and watch the outline and the checks change.

Part 2: H tags in SEO

Now that you know how headings work in code, let’s use them for search.

What are H tags for in SEO?

H tags let us prioritize some keywords over others for Googlebot and give it more context about the page. The better Google understands our content, the more ways it can surface it: we show up for queries related to our main keyword and for the keywords in the H2 and H3. To choose them well, lean on solid keyword research.

The H1 is not the meta title

They are two different things. The meta title is what appears in the search results; the H1 is the headline on the page. They should be related, but they don’t need to be identical. I explain the first one in what is the meta title tag.

HTML code

<head>
  <title>H Tags in SEO: Examples and Best Practices</title>
</head>
<body>
  <h1>H tags in SEO</h1>
</body>

How it looks

In Google (the title tag)

eljoseoweb.com › ...H Tags in SEO: Examples and Best Practices | El JoseoLearn what H tags are, how to use H1, H2 and H3 and see code examples...

On the page (the h1)

H tags in SEO

Remember: the H1 should contain the main topic of the page. Google has said that using more than one H1 is not a problem, but one clear H1 is the best practice and keeps the structure easy to read, as the Google SEO Starter Guide suggests.

Where to place keywords

In SEO we usually place the keywords we care about in the H1, H2 and H3, because the further a tag is from the H1, the less weight it carries. Write them for people first.

✕ Wrong

<h1>SEO SEO services cheap SEO</h1>
<h2>best SEO cheap SEO agency SEO</h2>
<h2>SEO SEO SEO prices</h2>

SEO SEO services cheap SEO

best SEO cheap SEO agency SEO

SEO SEO SEO prices

Keyword stuffing. It reads badly and says nothing.

✓ Right

<h1>What is SEO</h1>
<h2>How SEO works</h2>
<h2>SEO for Google vs. SEO for YouTube</h2>
<h3>Which one to start with</h3>

What is SEO

How SEO works

SEO for Google vs. SEO for YouTube

Which one to start with

The main keyword in the H1 and natural variations in the H2 and H3.

Each subheading should answer a question your reader is likely to have. That is also how you earn extra queries.

A full SEO example

Here is a complete outline for an article targeting “how to make coffee”:

HTML code

<h1>How to make coffee at home</h1>
  <h2>What you need</h2>
    <h3>Coffee beans</h3>
    <h3>Equipment</h3>
  <h2>Step by step</h2>
  <h2>Common mistakes</h2>
  <h2>FAQ</h2>

How it looks

How to make coffee at home

What you need

Coffee beans

Equipment

Step by step

Common mistakes

FAQ

Quick checklist

  • One clear H1 with the main topic.
  • H2 for the main sections, H3 only inside an H2.
  • No skipped levels and no empty headings.
  • Keywords written naturally, never stuffed.
  • Don’t use headings just to make text bigger.
  • Don’t hide headings with CSS tricks.

Want to see more?

Watch the video where I explain H tags, how to use them and different ways to optimize them in a simple way. Hope you like it :) (the video is in Spanish)

Sources and further reading

Frequently asked questions

What are H tags?

They are the HTML elements from h1 to h6 that mark the titles and subtitles of a page and give it a hierarchy.

How many H1 tags should a page have?

The safe choice is one clear H1 with the main topic. Google says several are not an error, but a single H1 keeps the structure simple.

Do H tags help SEO?

Yes, they give Google context and help it understand the topics of the page, which can help it show the page for more related queries. They are a support, not a magic switch.

What is the difference between the H1 and the meta title?

The meta title appears in the search results; the H1 is the headline shown on the page. They should be related, not necessarily identical.

See the headings of your own site

Want to see the heading structure of your website, H1 to H6 in order, and spot a missing or duplicated H1 in seconds? The El Joseo extension shows it on any page.

👉 Download the El Joseo SEO extension

Conclusion

H tags are simple in code and powerful when used with judgment: one clear H1, logical levels and natural keywords. Use the playground above to test your own outline, and if you want a quick check of your site, try the free SEO audit, which reviews your H tags along with other on-page elements.

Portrait of Jose Miguel, SEO consultant

Written by

José Miguel

Creator of El Joseo and senior SEO specialist, with more than 5 years of experience in SEO for Google, SEO for YouTube and digital marketing.

  • Builds SEO strategies for companies in many industries
  • Teaches SEO on YouTube
  • Tests everything he explains on real websites

👉 Want me to help with your site’s SEO?

Keep learning

Want more SEO like this?

Leave your email and I'll let you know when I publish something new about SEO for Google.