HTML Headings

Beginner
8 min read
Updated: Nov 2026
6 examples
<h1>–<h6>

Definition and Usage

HTML headings are titles or subtitles on a webpage. They are defined with the <h1> to <h6> tags. <h1> is the most important heading; <h6> is the least important. Browsers add space before and after headings by default.

Why headings matter

Search engines use headings to index structure. Users skim pages by headings. Screen readers jump from heading to heading. A clear hierarchy helps everyone.

How should you structure them?

Use <h1> for the page title (one per page), <h2> for section titles, then <h3> for sub-sections. Do not skip levels just to change visual size.

Headings vs title

The <title> in <head> is metadata for the tab and search results. An <h1> is visible body content for the main topic. Both belong in a well-built page.

One h1 best practice.

Prefer a single <h1> that names the main topic of the page, then nest lower levels under it.

Not for styling.

Do not use headings only to make text big or bold. Use CSS font-size (or semantic tags) for appearance.

Default size is not the meaning.

Browsers shrink text from h1 to h6, but the tags mean hierarchy—you can restyle any level with CSS.

HTML Heading Syntax

Each heading level is a normal element with start tag, content, and end tag:

heading.html
<h1> Heading text </h1>
HTML
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>

Typical outline: <h1> page title → <h2> sections → <h3> sub-sections. Change visual size with CSS, not by picking the wrong level.

Core HTML Concepts

Rules that keep heading outlines useful:

ConceptMeaning
<h1>–<h6>Six heading levels from most to least important
One <h1>Best practice: one main topic heading per page
Sequential levelsh1 → h2 → h3; do not skip for style
<title> vs <h1>Tab/search metadata vs visible main heading
Structure, not styleHeadings mark outline; CSS controls size
SEO & a11ySearch engines and screen readers use the outline
Default marginsBrowsers add space above and below headings

Heading vs title

<title><h1>
LocationInside <head>Inside <body>
Visible on page?No (tab / bookmark)Yes
Main jobDocument name for UI & searchMain topic of the content

How to Use Headings in HTML

Practical habits for a clear outline.

  1. Write one descriptive <h1> for the page topic.
  2. Add <h2> for each major section.
  3. Use <h3> (and lower) only under the matching parent level.
  4. Keep a matching <title> in the head (can be similar wording).
  5. Never pick a lower level only because the text looks smaller.
  6. Restyle with CSS font-size when you need a different look.
GoalPattern
Page topic<h1>Travel Guide</h1>
Section<h2>Europe</h2>
Sub-section<h3>France</h3>
Custom size<h1 style="font-size: 2rem">…</h1>
Tab title<title>Travel Guide</title> in head

Live Preview

Compare all six levels, a proper outline, a skipped-level mistake, and CSS sizing.

Shows how heading levels render. Prefer outline over skipping levels for style.

Rendered page

This is heading 1

This is heading 2

This is heading 3

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>

HTML Examples

Six patterns: all levels, hierarchy, one h1, title vs h1, CSS size, and a full page.

Example 1 — Headings h1 to h6

HTML
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
Try It Yourself

How It Works

  1. Six tags cover all heading levels.
  2. h1 is most important; h6 is least.
  3. Default CSS makes higher levels look larger.
  4. Meaning first — pick the level that fits the outline.

Example 2 — Document Hierarchy

HTML
<h1>Travel Guide</h1>

<h2>Europe</h2>
<h3>France</h3>
<h3>Italy</h3>

<h2>Asia</h2>
<h3>India</h3>
<h3>Thailand</h3>
Try It Yourself

How It Works

  1. h1 names the whole page topic.
  2. h2 marks continents (major sections).
  3. h3 marks countries under each continent.
  4. No skipped levels between parent and child.

Example 3 — One h1 Best Practice

HTML
<h1>My Blog</h1>
<h2>Latest Posts</h2>
<p>A short intro to this week’s articles.</p>
<h2>About the Author</h2>
<p>Writer, teacher, and coffee enthusiast.</p>
Try It Yourself

How It Works

  1. Single h1 states the page subject.
  2. Sections use h2, not extra h1 tags.
  3. Screen readers get a clear top of the outline.
  4. Search engines see one primary topic signal.

Example 4 — Headings vs Title

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Gardening Tips for Beginners</title>
</head>
<body>
  <h1>Gardening Tips for Beginners</h1>
  <p>The title sets the tab name; the h1 greets readers on the page.</p>
</body>
</html>
Try It Yourself

How It Works

  1. title lives in head and is not page body text.
  2. h1 is the visible main heading.
  3. Similar wording is fine; jobs stay different.
  4. See also the HTML Head metadata tutorial.

Example 5 — Size Headings with CSS

HTML
<h1>Normal h1 size</h1>
<h1 style="font-size: 1.25rem">Same level, smaller look</h1>
<h2 style="font-size: 2rem">h2 that looks larger via CSS</h2>
<!-- Do not use <h3> just because you want smaller text -->
Try It Yourself

How It Works

  1. Keep the correct level for the outline.
  2. font-size changes appearance without skipping levels.
  3. Avoid using h3 merely because default text is smaller.
  4. Prefer stylesheets over inline styles in real projects.

Example 6 — Complete HTML Page

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML Headings Example</title>
</head>
<body>
  <h1>Welcome to My Website</h1>
  <h2>News</h2>
  <p>Today we launched a new HTML tutorial.</p>
  <h2>Tutorials</h2>
  <h3>HTML Basics</h3>
  <p>Start with elements, then headings and text.</p>
  <h3>CSS Basics</h3>
  <p>Style your headings without changing their levels.</p>
</body>
</html>
Try It Yourself

How It Works

  1. title names the document in the tab.
  2. One h1 introduces the site page.
  3. h2 / h3 build a sequential outline.
  4. Paragraphs follow each heading with content.

Edge Cases & Pitfalls

Broken outlines usually come from styling with heading tags or jumping levels.

skip

Skipping levels for style

Going from <h1> to <h3> confuses assistive tech. Use CSS instead.

style

Headings as bold text

Do not wrap random phrases in <h2> just to enlarge them.

h1

Many competing h1s

Multiple top-level headings blur the main topic. Prefer one clear <h1>.

title

Missing title or empty h1

Tabs and search need <title>; the page needs a meaningful visible heading.

order

Illogical order

An <h3> before any <h2> breaks the outline. Keep levels sequential.

empty

Empty heading with no content after

Each heading should label real content (text or a nested subheading).

Browser Support

HTML heading elements (h1–h6) are part of HTML and work in all browsers.

✓ Baseline · Widely available

HTML headings

Every browser styles h1–h6 by default and exposes them to assistive technologies.

100% heading elements
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
HTML headings Universal

Bottom line: Use h1–h6 for structure everywhere—then style with CSS when you need a custom look.

Key Takeaways

  • h1–h6 define importance and document structure—not just font size.
  • One h1 for the page topic; then h2, h3, and lower in order.
  • title ≠ h1 — tab metadata versus visible main heading.
  • Do not skip levels for style—use CSS font-size instead.

One line: Build a sequential outline with one <h1> and nested <h2>–<h6>, keep <title> for the tab, and style size with CSS—not by skipping levels.

Frequently Asked Questions

HTML headings are titles and subtitles defined with <h1> through <h6>. <h1> is the most important (main topic); <h6> is the least important. Browsers style them larger or smaller by default and add space around them.
Best practice is one <h1> per page for the main topic. Use <h2> for major sections, then <h3> for subsections, and so on. Multiple h1s are allowed by the HTML standard but usually hurt clarity and accessibility.
The <title> in the head is metadata for the browser tab, bookmarks, and often search results. An <h1> is a visible heading in the body for the page’s main topic. Use both; they serve different jobs.
Do not skip levels to change visual size (for example jumping from h1 to h3). Keep a logical outline: h1, then h2, then h3. Use CSS font-size if you need a different look.
No. Headings describe document structure. To enlarge or emphasize non-heading text, use CSS (or semantic tags like <strong> when meaning requires it), not h1–h6.
Search engines and screen-reader users rely on headings to understand and navigate page structure. Clear, sequential headings help both indexing and keyboard/screen-reader navigation.

Practice in the editor

Open a Try It demo and build a clean h1–h6 outline.

Open Try It editor →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful