HTML Heading Tags

Beginner
7 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <h1> through <h6> elements mark six levels of section headings. <h1> is the highest (main topic); <h6> is the lowest. By default they are block-level and take the full width of their container.

Use headings for structure, not as a way to enlarge text — size with CSS font-size instead. Prefer one <h1> per page, then nest <h2>, <h3>, and so on without skipping ranks. Do not confuse them with <header> (an intro container).

Baseline · Widely available.

Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).

Accessibility warning.

Do not skip heading levels (for example h1 then h3). Screen reader users often browse by headings and expect a continuous outline.

HTML Syntax

syntax.html
<h 1–6>heading text</hn>

Both start and end tags are required. Content is phrasing content (text and inline markup). Implicit ARIA role is heading with a matching level.

Attributes

Heading elements have no element-specific attributes — only global attributes.

AttributeDescriptionNotes
None specificNo dedicated attributes on <h1>–<h6>.Use id for in-page links and class for styling.
Experimental.

Global headingoffset / headingreset can change the computed heading level for assistive tech. Limited support — do not rely on them in production yet.

Global Attributes

The heading tags also support the Global Attributes in HTML.

Live Preview

Change the heading level and see how default size and rank look in the outline.

Rank matters more than looks — CSS can change size without changing the tag.

Heading

Heading level 1

<h1>Heading level 1</h1>

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — All Six Heading Levels

Show h1 through h6 in order.

HTML
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>
Try It Yourself

How It Works

  1. Pick a level from 1 (highest) to 6 (lowest).
  2. Wrap the title text in matching start and end tags.
  3. Default fonts shrink as the level number grows — that is presentation, not the reason to choose a level.
  4. Choose the level for meaning in the outline, then restyle with CSS if needed.

Example 2 — Nested Outline (No Skips)

Build subsections with consecutive levels, like a table of contents.

HTML
<h1>Beetles</h1>

<h2>External morphology</h2>
<h3>Head</h3>
<h4>Mouthparts</h4>

<h3>Thorax</h3>
<h4>Prothorax</h4>
<h4>Pterothorax</h4>
Try It Yourself

How It Works

  1. Start with <h1> for the page (or main topic) title.
  2. Use <h2> for major sections under that topic.
  3. Nest <h3> / <h4> for subsections — step down one level at a time.
  4. When a subsection ends, you may return to a previous level (for example another h3 after an h4).

Example 3 — Typical Article Page

One h1, then h2 sections with short content under each.

HTML
<h1>Heading elements</h1>

<h2>Summary</h2>
<p>Headings organize a page into sections.</p>

<h2>Examples</h2>
<h3>Example 1</h3>
<p>A basic outline starts with h1, then h2.</p>

<h3>Example 2</h3>
<p>Subsections use the next level down.</p>

<h2>See also</h2>
<p>Related tags include header and section.</p>
Try It Yourself

How It Works

  1. Name the page with a single <h1>.
  2. Split topics with <h2> sections.
  3. Add details under an <h3> when a section needs parts.
  4. Keep body text in <p> (or other content tags) under the matching heading.

Example 4 — Change Size with CSS, Keep the Level

Keep a correct h2 for meaning; restyle appearance separately.

HTML
<style>
  .section-title {
    font-size: 1.75rem;
    color: #1d4ed8;
  }
</style>

<h1>Course guide</h1>
<h2 class="section-title">Lesson 1</h2>
<p>This h2 looks large, but it remains level 2 in the outline.</p>
Try It Yourself

How It Works

  1. Choose the correct level for the outline (h2 under h1).
  2. Add a class for visual design.
  3. Set font-size (and color) in CSS — not by swapping to h1 just to look bigger.
  4. Assistive tech still hears “heading level 2,” which keeps navigation honest.

Edge Cases & Pitfalls

Most heading bugs are skipped levels, fake big text, or too many h1s.

a11y

Do not skip levels

Avoid h1 → h3. Screen reader users rely on a continuous outline when jumping headings.

seo

Prefer one h1

Multiple h1s are allowed but not recommended. One clear page title works best for people and search engines.

style

Not a font tool

Never pick h1 only because it looks bigger. Use CSS font-size on the correct level.

names

heading ≠ header ≠ title

h1–h6 are headings. <header> is a container. <title> is the document tab name in <head>.

history

No outline algorithm trick

Do not rely on old “sectioning resets the outline” ideas. Rank headings explicitly with the right h* level.

Browser Support

The <h1>–<h6> elements are core HTML heading content in every browser. They are not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<h1>–<h6>

Widely available since about July 2015 (and long before). Chrome, Firefox, Safari, Edge, and Opera all support heading elements with default block styling.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
Headings Widely supported

Bottom line: Safe to use everywhere. Focus on a clean outline: one main h1, no skipped levels, CSS for looks.

Key Takeaways

  • Levels: h1–h6 rank section titles from highest to lowest.
  • Outline: prefer one h1; nest without skipping ranks.
  • Style: change size with CSS, not by misusing heading tags.
  • Names: headings ≠ header container ≠ document title.

One line: pick the heading level for the outline first, then make it look right with CSS.

Default CSS Settings

Typical user-agent defaults (exact values vary by browser):

default.css
h1 {
  display: block;
  font-size: 2em;
  margin-block: 0.67em;
  font-weight: bold;
}

h2 {
  display: block;
  font-size: 1.5em;
  margin-block: 0.83em;
  font-weight: bold;
}

h3 {
  display: block;
  font-size: 1.17em;
  margin-block: 1em;
  font-weight: bold;
}

h4 {
  display: block;
  margin-block: 1.33em;
  font-weight: bold;
}

h5 {
  display: block;
  font-size: 0.83em;
  margin-block: 1.67em;
  font-weight: bold;
}

h6 {
  display: block;
  font-size: 0.67em;
  margin-block: 2.33em;
  font-weight: bold;
}

Override freely for design, but keep the HTML levels meaningful for the outline.

Frequently Asked Questions

The h1–h6 elements mark six levels of section headings. h1 is the highest (most important) level; h6 is the lowest.
Prefer one h1 that names the main topic of the page (similar in spirit to the document title). Multiple h1s are allowed by the standard but are not best practice.
Avoid it. Screen reader users often jump heading by heading; skipped levels make the outline confusing. Nest subsections without jumping ranks.
No. Use CSS font-size for visual size. Headings exist for structure, SEO, and accessibility — not as a font shortcut.
No. h1–h6 are heading elements. The header element is a container for introductory content that may include a heading.
Browsers and assistive tools can build a contents list from headings. Keep levels ordered so that outline is useful.

Next: hr

Add a thematic break between sections with the HTML hr element.

hr tutorial →

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.

12 people found this page helpful