HTML headings are used to define titles and subtitles on a web page. They are one of the most important structural elements in HTML.
HTML provides six levels of headings, from <h1> (most important / largest) to <h6> (least important / smallest):
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Here is how each heading looks in a browser:
| Tag | Description | Default Size |
|---|---|---|
<h1> | Most important heading — page title | 2em (32px) |
<h2> | Section heading | 1.5em (24px) |
<h3> | Sub-section heading | 1.17em (~18.7px) |
<h4> | Sub-sub-section heading | 1em (16px) |
<h5> | Minor heading | 0.83em (~13.3px) |
<h6> | Least important heading | 0.67em (~10.7px) |
Search engines use headings to understand the structure and topic of your page. The <h1> heading carries the most weight for SEO:
<h1> per page — it should describe the main topic<h2> for major sections<h3> for sub-sections under <h2><h1> to <h3>)<h1> to understand what the page is about. Make it descriptive, keyword-rich, and unique for every page.
Think of headings like a document outline. Here is a good structure for a web page:
<h1>Learn HTML</h1> <!-- Page title -->
<h2>Introduction</h2> <!-- Section 1 -->
<h3>What is HTML?</h3> <!-- Sub-section -->
<h3>History of HTML</h3> <!-- Sub-section -->
<h2>HTML Elements</h2> <!-- Section 2 -->
<h3>Tags</h3>
<h3>Attributes</h3>
<h2>HTML Forms</h2> <!-- Section 3 -->
You can change the size of any heading using the style attribute and the font-size CSS property:
<h1 style="font-size: 60px;">Very Large Heading</h1>
<h1 style="font-size: 20px;">Small h1 Heading</h1>
<p> or <span> instead.
<h1>.
<h3> over <h2> just because it renders at the font size you want — style the existing heading with CSS instead.
<h1> straight to <h4> breaks the document outline that screen-reader users navigate by section.
A properly nested heading structure for a short blog post:
<h1>5 Tips for a Faster Website</h1>
<h2>1. Compress Your Images</h2>
<h3>Choosing the right format</h3>
<h3>Using lazy loading</h3>
<h2>2. Minify CSS and JavaScript</h2>
<h2>3. Use a Content Delivery Network</h2>
Rendered result:
(Sizes above are reduced with Bootstrap classes just so the outline fits on this page — in real use you'd let the browser's default heading sizes apply.)
Q: How many <h1> tags should a page have?
A: Exactly one. It should describe the main topic of that specific page.
Q: Do headings affect SEO ranking directly?
A: Search engines use headings to understand page structure and topic relevance, but a heading alone won't rank a page — it needs to accurately describe genuinely useful content underneath it.
Q: Can I skip from <h1> to <h4>?
A: You can, and the page will still render, but it's considered bad practice — see the MDN heading elements guide for how the outline should nest.